function autosubmit()
{
   if (event.keyCode==13)
   {
   		validatelogin()
   }	
}
function IsNumeric(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }

function roll(img_name, img_src)
{
   //alert(img_src)
   document[img_name].src = img_src;
}
function BrowseShirts()
{
	document.getElementById("WelcomeSection").style.display="none"
	document.getElementById("EditShirtSection").style.display="none"
	document.getElementById("BrowseShirtSection").style.display=""
	document.getElementById("AddShirtSection").style.display="none"
	
}
function CreateNewGarmentClick()
{
	document.getElementById("WelcomeSection").style.display="none"
	document.getElementById("EditShirtSection").style.display="none"
	document.getElementById("BrowseShirtSection").style.display="none"
	document.getElementById("AddShirtSection").style.display=""
}
function submitnewgarmentdetails()
{
	document.getElementById("wait").style.display="";
	var section = "submitnewgarmentdetails"
	var garmentcategory = document.getElementById("garmentcategory").value
	var garmentname =  document.getElementById("garmentname").value
	//checkboxes
	var extrasection= 0
	var collarsection = 0
	if (document.addgarment.extrasection.checked)
	{
		extrasection = 1
	}
	if (document.addgarment.collarsection.checked)
	{
		collarsection = 1
	}
document.hidden.location="db/addnew.asp?section="+section+"&garmentcategory="+garmentcategory+"&garmentname="+garmentname+"&extrasection="+extrasection+"&collarsection="+collarsection
}
function submitnewgarmentimage()
{
	document.frm1.submit()
}
function cleandata()
{
	document.hidden.location="db/cleandata.asp"
	
}
function validatelogin()
{
	var cont='yes'
	//alert('<%=MainPath%>')
	if(document.getElementById("username").value=='')
	{
		alert("Please enter a valid username")
		document.getElementById("username").focus()
		cont='no'
		return false;
	}

	if(document.getElementById("password").value=='')
	{
		alert("Please enter a valid password")
		document.getElementById("password").focus()
		cont='no'
		return false;
	}
	if (cont=='yes')
	{
		frames['innerhidden'].location.href = "/client/MKKSports/db/loginauth.asp?username="+document.getElementById("username").value+"&password="+document.getElementById("password").value+"&referrerpage="+document.getElementById("referrerpage").value
	}
}

function roll(img_name, img_src)
   {
   //alert(img_src)
   document[img_name].src = img_src;
   }
   
function BrowseUserAccounts()
{
	window.location.href  = "useraccounts.asp"
}

function CreateAccessory()
{
	window.location.href  = "accessories.asp"
}
function addeditgarmenttype()
{
	window.location.href  = "garmenttypes.asp"
}
function UploadAccessoryImages()
{
	window.location.href  = "UploadAccessoryImages.asp"
}
function addeditcolour()
{
	window.location.href  = "colours.asp"	
}
function addeditstyle()
{
	window.location.href  = "styles.asp"
}
function addeditposition()
{
	window.location.href  = "positions.asp"
}
function CreateGarment()
{
	window.location.href  = "garments.asp"
}
function deleteimages()
{
	window.location.href  = "DeleteImages.asp"
}
function definecoordinates()
{
    window.location.href  = "AddEditCoordinates.asp"
}
function deleteaccount(theuserid,thefirstname,thelastname)
{
	var answer = confirm("Are you sure you want to disable the account of "+thefirstname+ " " + thelastname +"?")
	if (answer)
	{
		frames['hidden'].location.href = "/client/MKKSports/db/activateuser.asp?userid="+theuserid+"&action=disable"
	}	
}
function enableaccount(theuserid,thefirstname,thelastname)
{
	var answer = confirm("Are you sure you want to enable the account of "+thefirstname+ " " + thelastname +"?")
	if (answer)
	{
		frames['hidden'].location.href = "/client/MKKSports/db/activateuser.asp?userid="+theuserid+"&action=enable"
	}	
}

function disableaccessory(accessoryid,accessoryname)
{
	var answer = confirm("Are you sure you want to disable the accessory "+accessoryname+"? (Accessory will not be displayed on the main website)")
	if (answer)
	{
		frames['hidden'].location.href = "/client/MKKSports/db/activateaccessory.asp?accessoryid="+accessoryid+"&action=disable"
	}	
}
function enableaccessory(accessoryid,accessoryname)
{
	var answer = confirm("Are you sure you want to enable the accessory "+accessoryname+"? (Accessory will be displayed on the main website)")
	if (answer)
	{
		frames['hidden'].location.href = "/client/MKKSports/db/activateaccessory.asp?accessoryid="+accessoryid+"&action=enable"
	}	
}


function reloadpage()
{
	window.location.href  =	window.location.href 
}
function edituseraccount(userid)
{
	document.getElementById("userdetails_"+userid).style.display=''
}
function editaccessorysection(AccessoryID)
{
	document.getElementById("Accessorydetailstable_"+AccessoryID).style.display=''
}
function editsport(theid)
{
	document.getElementById("sportdetails_"+theid).style.display=''
}
function uneditsport(theid)
{
	document.getElementById("sportdetails_"+theid).style.display='none'
}
function editLevel(theid)
{
	document.getElementById("leveldetails_"+theid).style.display=''
}
function uneditLevel(theid)
{
	document.getElementById("leveldetails_"+theid).style.display='none'
}
function uneditaccessorysection(AccessoryID)
{
	document.getElementById("Accessorydetailstable_"+AccessoryID).style.display='none'
}

function editcolour(colourid,theaction)
{
	if(theaction=='U') //Update
	{
		document.getElementById("colourdetails_"+colourid).style.display=''
	}
	if(theaction=='D') //Disable
	{
		var answer = confirm("Are you sure you want to disable this colour?")
		if (answer)
		{
			var thecolourid = colourid
			frames['hidden'].location.href = "/client/MKKSports/db/updatecolour.asp?colourid="+colourid+"&theaction=disable"
		}	
	}
	if(theaction=='E') //Enable
	{
		var answer = confirm("Are you sure you want to enable this colour?")
		if (answer)
		{
			var thecolourid = colourid
			frames['hidden'].location.href = "/client/MKKSports/db/updatecolour.asp?colourid="+colourid+"&theaction=enable"
		}	
	}
	
}
function editposition(positionid)
{
		document.getElementById("positiondetails_"+positionid).style.display=''
}
function uneditposition(positionid)
{
		document.getElementById("positiondetails_"+positionid).style.display='none'
}
function editgarmenttype(garmenttypeid)
{
		document.getElementById("garmenttypedetails_"+garmenttypeid).style.display=''
}
function uneditgarmenttype(garmenttypeid)
{
		document.getElementById("garmenttypedetails_"+garmenttypeid).style.display='none'
}


function editgarment(garmentid)
{
		document.getElementById("garmentdetailstable_"+garmentid).style.display=''
}
function uneditgarment(garmentid)
{
		document.getElementById("garmentdetailstable_"+garmentid).style.display='none'
}

function editstyle(styleid)
{
	document.getElementById("styledetails_"+styleid).style.display=''
}
function uneditstyle(styleid)
{
	document.getElementById("styledetails_"+styleid).style.display='none'
}
function uneditcolour(colourid)
{
	document.getElementById("colourdetails_"+colourid).style.display='none'
}
function editaccessory(accessoryid)
{
	
	document.getElementById("accessorydetails_"+accessoryid).style.display=''
}

function unedituseraccount(userid)
{
	document.getElementById("userdetails_"+userid).style.display='none'
}
function uneditaccessory(accessoryid)
{
		document.getElementById("accessorydetails_"+accessoryid).style.display='none'
}

function editcoordinates(coordinateid)
{
    document.getElementById("coordinatedetails_"+coordinateid).style.display=''
}
function  uneditcoordinates(coordinateid)
{
    document.getElementById("coordinatedetails_"+coordinateid).style.display='none'
}


function emailuserpassword(userid)
{
	frames['hidden'].location.href = "/client/MKKSports/db/emailuserpassword.asp?userid="+userid
}
function updateuseraccount(userid)
{
	
	//Validate fields first
	if(document.getElementById("firstname_"+userid).value=='')
	{
		alert('Please enter a First Name for this user')
		document.getElementById("firstname_"+userid).focus()
		return false
	}
	if(document.getElementById("lastname_"+userid).value=='')
	{
		alert('Please enter a Last Name for this user')
		document.getElementById("lastname_"+userid).focus()
		return false
	}
	if(document.getElementById("UserID_"+userid).value=='')
	{
		alert('Please enter an email address for this user (very important)')
		document.getElementById("UserID_"+userid).focus()
		return false
	}
	if(document.getElementById("AccessLevel_"+userid).value=='')
	{
		alert('Please enter a access level for this user (1-3)')
		document.getElementById("AccessLevel_"+userid).focus()
		return false
	}
	
	//Check if password reset
	if(document.getElementById("password_"+userid).value.length > 0 || document.getElementById("password2_"+userid).value.length > 0)
	{
		if (document.getElementById("password_"+userid).value=='' || document.getElementById("password2_"+userid).value=='' || document.getElementById("password_"+userid).value.length < 5 || document.getElementById("password2_"+userid).value.length<5)
			{
				alert('Please enter a password in both password and confirm password fields (minimum length of 5 characters)')
				document.getElementById("password_"+userid).focus();
				return false;
			}
			else
			{
				if (document.getElementById("password_"+userid).value!=document.getElementById("password2_"+userid).value)
				{
					alert('Please re-enter your passwords as they do not match');
					document.getElementById("password_"+userid).focus();
					return false;
				}
			} 
	}
var firstname = document.getElementById("firstname_"+userid).value
var lastname = document.getElementById("lastname_"+userid).value
var email = document.getElementById("UserID_"+userid).value
var AccessLevel = document.getElementById("AccessLevel_"+userid).value
var thepassword
if(document.getElementById("password_"+userid).value.length > 0 || document.getElementById("password2_"+userid).value.length > 0)//This should of been validated already
	{
		thepassword = 	document.getElementById("password_"+userid).value
	}
else
	{
		thepassword = 	document.getElementById("oldpassword_"+userid).value	
	}

frames['hidden'].location.href = "/client/MKKSports/db/updateuserdetails.asp?userid="+userid+"&firstname="+firstname+"&lastname="+lastname+"&email="+email+"&AccessLevel="+AccessLevel+"&thepassword="+thepassword
	
}
function updatecolour(colourid)
{
	//Validate fields first
	if(document.getElementById("colourname_"+colourid).value=='')
	{
		alert('Please enter a Colour name')
		document.getElementById("colourname_"+colourid).focus()
		return false
	}
	if(document.getElementById("colourcode_"+colourid).value=='')
	{
		alert('Please enter a Colour Code')
		document.getElementById("colourcode_"+colourid).focus()
		return false
	}
	if(document.getElementById("colourhex_"+colourid).value=='')
	{
		alert('Please enter a Colour Hex Code')
		document.getElementById("colourhex_"+colourid).focus()
		return false
	}
	if(document.getElementById("colourdisplay_"+colourid).value=='')
	{
		alert('Please enter a colour to Display on the web')
		document.getElementById("colourdisplay_"+colourid).focus()
		return false
	}
	
	var answer = confirm("You are about to make quite important changes to a colour that may already of existed on currently stored garments.\n\nPlease be sure you want to go ahead and do this. Seek advise if need be.")
	if (answer)
	{
		var thecolourid = colourid
		var colourname=document.getElementById("colourname_"+colourid).value
		var colourcode=document.getElementById("colourcode_"+colourid).value
		var colourhex=document.getElementById("colourhex_"+colourid).value
		colourhex = colourhex.replace("#","")
		var colourdisplay=document.getElementById("colourdisplay_"+colourid).value
		frames['hidden'].location.href = "/client/MKKSports/db/updatecolour.asp?colourid="+colourid+"&colourname="+colourname+"&colourcode="+colourcode+"&colourhex="+colourhex+"&colourdisplay="+colourdisplay
	}	


}
function newcolour()
{
	if(document.getElementById("newcolourname").value=='')
	{
		alert('Please enter a Colour name')
		document.getElementById("newcolourname").focus()
		return false
	}
	if(document.getElementById("newcolourcode").value=='')
	{
		alert('Please enter a Colour Code')
		document.getElementById("newcolourcode").focus()
		return false
	}
	if(document.getElementById("newcolourhex").value=='')
	{
		alert('Please enter a Colour Hexidecimal code')
		document.getElementById("newcolourhex").focus()
		return false
	}
	if(document.getElementById("newcolourdisplay").value=='')
	{
		alert('Please enter a the colour name to display on the website')
		document.getElementById("newcolourdisplay").focus()
		return false
	}
	var colourname=document.getElementById("newcolourname").value
	var colourcode=document.getElementById("newcolourcode").value
	var colourhex=document.getElementById("newcolourhex").value
	colourhex = colourhex.replace("#","")
	var colourdisplay=document.getElementById("newcolourdisplay").value
	frames['hidden'].location.href = "/client/MKKSports/db/newcolour.asp?colourname="+colourname+"&colourcode="+colourcode+"&colourhex="+colourhex+"&colourdisplay="+colourdisplay
}
function newuseraccount()
{
	//Validate fields first
	if(document.getElementById("newfirstname").value=='')
	{
		alert('Please enter a First Name for this user')
		document.getElementById("newfirstname").focus()
		return false
	}
	if(document.getElementById("newlastname").value=='')
	{
		alert('Please enter a Last Name for this user')
		document.getElementById("newlastname").focus()
		return false
	}
	if(document.getElementById("newUserID").value=='')
	{
		alert('Please enter an email address for this user (very important)')
		document.getElementById("newUserID").focus()
		return false
	}
	if(document.getElementById("newAccessLevel").value=='')
	{
		alert('Please enter a access level for this user (1-3)')
		document.getElementById("newAccessLevel").focus()
		return false
	}
	if(document.getElementById("newActive").value=='')
	{
		alert('Please enter if the user account should be active (1) or not (0)')
		document.getElementById("newActive").focus()
		return false
	}
	//Check password
	if(document.getElementById("newpassword").value.length == 0 || document.getElementById("newpassword2").value.length == 0)
	{
		alert('Please enter a password in both password and confirm password fields (minimum length of 5 characters).')
		document.getElementById("newpassword").focus();
		return false;
	}
	else //Check passwords match
	{
			if (document.getElementById("newpassword").value!=document.getElementById("newpassword2").value)
			{
				alert('Please re-enter your passwords as they do not match');
				document.getElementById("newpassword").focus();
				return false;
			}
	}
	//Check Access level is correct
	if(document.getElementById("newAccessLevel").value < 1 || document.getElementById("newAccessLevel").value > 3) 
	{
		alert('Please enter an access level for this user between 1 and 3')
		document.getElementById("newAccessLevel").focus()
		return false
	}
	
	
	if(echeck(document.getElementById("newUserID").value))
	{
		var firstname = document.getElementById("newfirstname").value
		var lastname =  document.getElementById("newlastname").value
		var email = document.getElementById("newUserID").value
		var AccessLevel =  document.getElementById("newAccessLevel").value
		var thepassword = document.getElementById("newpassword").value
     	var Active = document.getElementById("newActive").value
		
	
	frames['hidden'].location.href = "/client/MKKSports/db/newuser.asp?firstname="+firstname+"&lastname="+lastname+"&email="+email+"&AccessLevel="+AccessLevel+"&thepassword="+thepassword+"&active="+Active
	 }

}
//Email validation
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		var cont
		cont = "yes"
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail address, please enter the address again.")
		   cont = "no"
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail address, please enter the address again.")
		   cont = "no"
		  return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail address, please enter the address again.")
			cont = "no"
		   return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail address, please enter the address again.")
			cont = "no"
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail address, please enter the address again.")
			cont = "no"
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail address, please enter the address again.")
			cont = "no"
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail address, please enter the address again.")
			cont = "no"
		    return false
		 }
return cont;
}

function updateaccessory(accessoryid)
{
	
	if(document.getElementById("accessoryname_"+accessoryid).value=='')
	{
		alert('Please enter an accessory name')
		document.getElementById("accessoryname_"+accessoryid).focus()
		return false;
	}
	if(document.getElementById("BodySection_"+accessoryid).value=='')
	{
		alert('Please enter a Body Section (top or bottom)')
		document.getElementById("BodySection_"+accessoryid).focus()
		return false;
	}
	
	//alert(document.getElementById("BodySection_"+garmentid).value.toLowerCase())
	if (document.getElementById("BodySection_"+accessoryid).value.toLowerCase() == 'top' || document.getElementById("BodySection_"+accessoryid).value.toLowerCase() == 'bottom')
	{
			
	}
	else
	{
		alert('For the Body Section, please only enter top or bottom')
		document.getElementById("BodySection_"+accessoryid).focus()
		return false;
	}
	var accessoryname=document.getElementById("accessoryname_"+accessoryid).value
	var bodysection = document.getElementById("BodySection_"+accessoryid).value
	
	
	frames['hidden'].location.href = "/client/MKKSports/db/updateaccessory.asp?accessoryid="+accessoryid+"&accessoryname="+accessoryname+"&bodysection="+bodysection
}
function updategarment(garmentid)
{
	if(document.getElementById("garmenttype_"+garmentid).value=='0')
	{
		alert('Please select a garment type')
		document.getElementById("garmenttype_"+garmentid).focus()
		return false;
	}
	if(document.getElementById("style_"+garmentid).value=='0')
	{
		alert('Please select a style')
		document.getElementById("style_"+garmentid).focus()
		return false;
	}
	if(document.getElementById("colour_"+garmentid).value=='0')
	{
		alert('Please select a colour')
		document.getElementById("colour_"+garmentid).focus()
		return false;
	}
	if(document.getElementById("theimage"+garmentid).value=='0')
	{
		alert('Please enter a fileaname')
		document.getElementById("theimage"+garmentid).focus()
		return false;
	}
	var garmenttype = document.getElementById("garmenttype_"+garmentid).value
	var style = document.getElementById("style_"+garmentid).value
	var colour = document.getElementById("colour_"+garmentid).value
	var theimage = document.getElementById("theimage"+garmentid).value
	
	
	frames['hidden'].location.href = "/client/MKKSports/db/updategarments.asp?garmentid="+garmentid+"&garmenttype="+garmenttype+"&style="+style+"&colour="+colour+"&theimage="+theimage+"&action=none"
}


function updatecoordinates(coordinateid)
{
    if(document.getElementById("top_"+coordinateid).value=='')
	{
		alert('Please enter a top coordinate!')
		document.getElementById("top_"+coordinateid).focus()
		return false;
	}
	  if(document.getElementById("left_"+coordinateid).value=='')
	{
		alert('Please enter a left coordinate!')
		document.getElementById("left_"+coordinateid).focus()
		return false;
	}
    
    var garmenttype = document.getElementById("garmenttype_"+coordinateid).value
    var AccessoryName = document.getElementById("AccessoryName_"+coordinateid).value
    var position = document.getElementById("position_"+coordinateid).value
    var top = document.getElementById("top_"+coordinateid).value
    var left = document.getElementById("left_"+coordinateid).value
    

    
    frames['hidden'].location.href = "/client/MKKSports/db/updatecoordinates.asp?coordinateid="+coordinateid+"&garmenttype="+garmenttype+"&AccessoryName="+AccessoryName+"&position="+position+"&top="+top+"&left="+left+"&action=update"
   
    
    
}

function newcoordinates()
{
    var garmenttype = document.getElementById("newgarmenttype").value
    var AccessoryName = document.getElementById("newAccessoryName").value
    var position = document.getElementById("newposition").value
    var top = document.getElementById("newtop").value
    var left = document.getElementById("newleft").value
    
    if(top=='')
	{
		alert('Please enter a TOP coordinate')
		document.getElementById("newtop").focus()
		return false
	}
	if(left=='')
	{
		alert('Please enter a LEFT coordinate')
		document.getElementById("newleft").focus()
		return false
	}
	
	if(IsNumeric(top)==false)
	{
	    alert('Please enter a numeric value for the top coordinate')
	    document.getElementById("newtop").focus()
	    return false
	}
	if(IsNumeric(left)==false)
	{
	    alert('Please enter a numeric value for the left coordinate')
	    document.getElementById("false").focus()
	    return false
	}
	
	frames['hidden'].location.href = "/client/MKKSports/db/updatecoordinates.asp?garmenttype="+garmenttype+"&AccessoryName="+AccessoryName+"&position="+position+"&top="+top+"&left="+left+"&action=insert" 
    
}//IsNumeric(sText)



function newaccessory()
{
	if(document.getElementById("newaccessoryname").value=='')
	{
		alert('Please enter an Accessory Name')
		document.getElementById("newaccessoryname").focus()
		return false
	}
	if(document.getElementById("newbodysection").value=='')
	{
		alert('Please enter a Body Section')
		document.getElementById("newbodysection").focus()
		return false
	}
	
	var accessoryname = document.getElementById("newaccessoryname").value
	var bodysection = document.getElementById("newbodysection").value
	//var pagename =  document.getElementById("newpagename").value
	var active = document.getElementById("accessoryactive").value
	frames['hidden'].location.href = "/client/MKKSports/db/newaccessory.asp?accessoryname="+accessoryname+"&bodysection="+bodysection+"&active="+active

}

function insertnewgarment()
{
	if(document.getElementById("garmenttype").value=='')
	{
		alert('Please select a Garment Type')
		document.getElementById("garmenttype").focus()
		return false
	}
	if(document.getElementById("garmentname").value=='')
	{
		alert('Please enter a Garment name')
		document.getElementById("garmentname").focus()
		return false
	}
	if(document.getElementById("garmentcolour").value=='')
	{
		alert('Please enter a Garment Colour')
		document.getElementById("garmentcolour").focus()
		return false
	}
	if(document.getElementById("theimage").value=='')
	{
		alert('Please choose an image name')
		document.getElementById("theimage").focus()
		return false
	}
	var garmenttype = document.getElementById("garmenttype").value
	var garmentname = document.getElementById("garmentname").value
	var garmentcolour = document.getElementById("garmentcolour").value
	var theimage =  document.getElementById("theimage").value
	var active = document.getElementById("garmentactive").value

frames['hidden'].location.href = "/client/MKKSports/db/newgarment.asp?garmenttype="+garmenttype+"&garmentname="+garmentname+"&garmentcolour="+garmentcolour+"&theimage="+theimage+"&active="+active
}
function updatestyle(styleid)
{
	if(document.getElementById("stylename_"+styleid).value=='')
	{
		alert('Please enter a Style Name')
		document.getElementById("stylename_"+styleid).focus()
		return false;
	}
	var thestyleid = styleid
	var stylename = document.getElementById("stylename_"+styleid).value
	frames['hidden'].location.href = "/client/MKKSports/db/updatestyle.asp?styleid="+styleid+"&stylename="+stylename+"&action=none"
}
function enablestyle(styleid)
{
	var answer = confirm("Are you sure you want to enable this style?")
	if (answer)
	{
		frames['hidden'].location.href = "/client/MKKSports/db/updatestyle.asp?styleid="+styleid+"&action=enable"
	}	
}
function disablestyle(styleid)
{
	var answer = confirm("Are you sure you want to disable this style?")
	if (answer)
	{
		frames['hidden'].location.href = "/client/MKKSports/db/updatestyle.asp?styleid="+styleid+"&action=disable"
	}	
}

function enableLevel(theid)
{
	var answer = confirm("Are you sure you want to enable this Top Level?")
	if (answer)
	{
		frames['hidden'].location.href = "/client/MKKSports/db/updatelevel.asp?levelid="+theid+"&action=enable"
	}	
}
function disableLevel(theid)
{
	var answer = confirm("Are you sure you want to disable this Top Level?")
	if (answer)
	{
		frames['hidden'].location.href = "/client/MKKSports/db/updatelevel.asp?levelid="+theid+"&action=disable"
	}	
}
function updatelevelname(theid)
{
	if(document.getElementById("LevelName_"+theid).value=='')
	{
		alert('Please enter a Level Name')
		document.getElementById("LevelName_"+theid).focus()
		return false;
	}
	var thelevelname = document.getElementById("LevelName_"+theid).value
	frames['hidden'].location.href = "/client/MKKSports/db/updatelevel.asp?levelid="+theid+"&action=update&levelname="+thelevelname
}

function disablegarment(garmentid)
{
	
	var answer = confirm("Are you sure you want to disable this garment (will not be shown on main site)?")
	if (answer)
	{
		frames['hidden'].location.href = "/client/MKKSports/db/updategarments.asp?garmentid="+garmentid+"&action=disable"
	}	
}
function enablegarment(garmentid)
{
	var answer = confirm("Are you sure you want to enable this garment?")
	if (answer)
	{
		frames['hidden'].location.href = "/client/MKKSports/db/updategarments.asp?garmentid="+garmentid+"&action=enable"
	}	
}
function enableposition(positionid)
{
	var answer = confirm("Are you sure you want to enable this position?")
	if (answer)
	{
		frames['hidden'].location.href = "/client/MKKSports/db/updateposition.asp?positionid="+positionid+"&action=enable"
	}	
}
function enablegarmenttype(garmenttypeid)
{
	var answer = confirm("Are you sure you want to enable this garment type?")
	if (answer)
	{
		frames['hidden'].location.href = "/client/MKKSports/db/updategarmenttype.asp?garmenttypeid="+garmenttypeid+"&action=enable"
	}	
}
function disablegarmenttype(garmenttypeid)
{
	var answer = confirm("Are you sure you want to disable this garment type?")
	if (answer)
	{
		frames['hidden'].location.href = "/client/MKKSports/db/updategarmenttype.asp?garmenttypeid="+garmenttypeid+"&action=disable"
	}	
}
function disableposition(positionid)
{
	var answer = confirm("Are you sure you want to disable this position?")
	if (answer)
	{
		frames['hidden'].location.href = "/client/MKKSports/db/updateposition.asp?positionid="+positionid+"&action=disable"
	}	
}
function updateposition(positionid)
{
	if(document.getElementById("positionname_"+positionid).value=='')
	{
		alert('Please enter a Position Name')
		document.getElementById("positionname_"+positionid).focus()
		return false;
	}
	var thepositionid = positionid
	var positionname = document.getElementById("positionname_"+positionid).value
	frames['hidden'].location.href = "/client/MKKSports/db/updateposition.asp?positionid="+thepositionid+"&positionname="+positionname+"&action=none"
}

function updategarmenttype(garmenttypeid)
{
	
	
	if(document.getElementById("garmenttypename_"+garmenttypeid).value=='')
	{
		alert('Please enter a Garment Type Name')
		document.getElementById("garmenttypename_"+garmenttypeid).focus()
		return false;
	}
	var garmenttypeid = garmenttypeid
	var garmenttypename = document.getElementById("garmenttypename_"+garmenttypeid).value
	frames['hidden'].location.href = "/client/MKKSports/db/updategarmenttype.asp?garmenttypeid="+garmenttypeid+"&garmenttypename="+garmenttypename+"&action=none"
}
function newposition()
{
	if(document.getElementById("newpositionname").value=='')
	{
		alert('Please enter a Position Name')
		document.getElementById("newpositionname").focus()
		return false;
	}
	var positionname=  document.getElementById("newpositionname").value
	var active = document.getElementById("positionactive").value
	frames['hidden'].location.href = "/client/MKKSports/db/newposition.asp?positionname="+positionname+"&active="+active	
}
function newgarmenttype()
{
	if(document.getElementById("newgarmenttypename").value=='')
	{
		alert('Please enter a Garment Type Name')
		document.getElementById("newgarmenttypename").focus()
		return false;
	}
	var garmenttypename=  document.getElementById("newgarmenttypename").value
	var active = document.getElementById("garmenttypeactive").value
	frames['hidden'].location.href = "/client/MKKSports/db/newgarmenttype.asp?garmenttypename="+garmenttypename+"&active="+active		
}

function newstyle()
{
	if(document.getElementById("newstylename").value=='')
	{
		alert('Please enter a Style Name')
		document.getElementById("newstylename").focus()
		return false;
	}
	var stylename=  document.getElementById("newstylename").value
	var active = document.getElementById("styleactive").value
	frames['hidden'].location.href = "/client/MKKSports/db/newstyle.asp?stylename="+stylename+"&active="+active
	
}
function reloadcomponentspage(thevalue)
{
	window.location.href  = "UploadComponentImagesIFRAME.asp?NumberofComponents="+thevalue
}
function reloadgarmentsspage(thevalue)
{
	window.location.href  = "UploadGarmentImagesIFRAME.asp?NumberofComponents="+thevalue
}
function yesnoall(numaccessories)
{
	if(document.getElementById("defaultyesno").checked)
	{
		//alert('yes')
		delselall(numaccessories,'selectedall')
	}
	else
	{
		//alert('no')
		delselall(numaccessories,'deselectedall')
	}
}
function delselall(numaccessories,theaction)
{
	for(var i=1; i <= numaccessories; i++)
	{
		if(theaction=='selectedall')
		{
			document.getElementById("defaultaccval"+i).value=1
		}
		else
		{
			document.getElementById("defaultaccval"+i).value=0
		}
	}

}

function verify_insert_accessory(numaccessories,imagetype)
{
	
	var i;
	var garment
	var style;
	var position;
	var accessory;
	var colour;
	var imagename;
	var cont;
	
	for (i=1;i<=numaccessories;i++)
	{
		
		
		garment = document.getElementById("garment"+i).value
		style = document.getElementById("style"+i).value
		position = document.getElementById("position"+i).value
		accessory = document.getElementById("accessory"+i).value
		colour = document.getElementById("colour"+i).value
		theimage = document.getElementById("theimage"+i).value
		
		var thearraystring
		thearraystring=""
		for(j=0; j<document.frm1.sporttype.length; j++)
		{
			if(document.frm1.sporttype[j].checked==true)
			{
				thearraystring = thearraystring + document.frm1.sporttype[j].value + ";"
			//alert(document.frm1.lookalikelist[i].value)
			}
		}
		
		if(imagetype=='none')
		{
			document.getElementById("complete"+i).style.display='none'
			document.getElementById("imageverify").style.display='none'
			document.getElementById("imageverifyt").style.display='none'
		}
		//Validation//
		if(garment=='0')
		{
			alert('Please select a garment name in following row: '+i)
			document.getElementById("garmenttd"+i).style.backgroundColor='#FFD60B'
			document.getElementById("garment"+i).focus()
			return false;
			
		}
		else
		{
			document.getElementById("garmenttd"+i).style.backgroundColor='#000000'
		}
		if(style=='0')
		{
			alert('Please select a style name in following row: '+i)
			document.getElementById("styletd"+i).style.backgroundColor='#FFD60B'
			document.getElementById("style"+i).focus()
			return false;
			
		}
		else
		{
			document.getElementById("styletd"+i).style.backgroundColor='#000000'
		}
		if(position=='0')
		{
			alert('Please select a position name in following row: '+i)
			document.getElementById("positiontd"+i).style.backgroundColor='#FFD60B'
			document.getElementById("position"+i).focus()
			return false;
			
		}
		else
		{
			document.getElementById("positiontd"+i).style.backgroundColor='#000000'
		}
		if(accessory=='0')
		{
			alert('Please select a accessory name in following row: '+i)
			document.getElementById("accessorytd"+i).style.backgroundColor='#FFD60B'
			document.getElementById("accessory"+i).focus()
			return false;
			
		}
		else
		{
			document.getElementById("accessorytd"+i).style.backgroundColor='#000000'
		}
		if(colour=='0')
		{
			alert('Please select a colour name in following row: '+i)
			document.getElementById("colourtd"+i).style.backgroundColor='#FFD60B'
			document.getElementById("colour"+i).focus()
			return false;
			
		}
		else
		{
			document.getElementById("colourtd"+i).style.backgroundColor='#000000'
		}
		if(theimage=='')
		{
			alert('Please select an image name in following row: '+i)
			document.getElementById("theimagetd"+i).style.backgroundColor='#FFD60B'
			document.getElementById("theimage"+i).focus()
			return false;
			
		}
		else
		{
			document.getElementById("theimagetd"+i).style.backgroundColor='#000000'
		}
		if(thearraystring=='')
		{
			alert('Please select a sport(s) for this accessory')
			document.getElementById("sporttype").focus()
			return false;
		}
		
		//Next thing to do is check images are being uploaded!
		//Check correct files are being uploaded
		var iLen1 = String(document.getElementById("theimage"+i).value).length;
		var ext1 = String(document.getElementById("theimage"+i).value).substring(iLen1, iLen1 - 3);
		if (ext1.toLowerCase()  == "gif" || ext1.toLowerCase() == "jpg" || ext1.toLowerCase() == "png")
		{
			//Good
		}
			else
		{
			alert ('Please provide a correct file format for file 1 (i.e. - jpg,gif,png) in following row: '+i)
			document.getElementById("theimagetd"+i).style.backgroundColor='#FFD60B'
			document.getElementById("theimage"+i).focus()
			return false;
		}
	//Tick Boxes
	document.getElementById("complete"+i).style.display=''
	} //Loop
	
	if(imagetype=='none')
	{
		//Show image checking part
		document.getElementById("imageverify").style.display=''
		document.getElementById("imageverifyt").style.display=''
		document.getElementById("errorupload").style.display='none'
		document.getElementById("imageverifyt").innerHTML='Please wait whilst images are checked'
	}
	document.getElementById("thesports").value=thearraystring
	document.frm1.submit()
	
	
	
}
function verify_insert_garment(numcomponents,imagetype)
{
	var i;
	var garmenttype;
	var style;
	var colour;
	var imagename;
	var cont;
	var sport;
	var thearraystring
	
	for (i=1;i<=numcomponents;i++)
	{
		thearraystring = ""
		garmenttype = document.getElementById("garmenttype"+i).value
		//alert(garmenttype)
		style = document.getElementById("style"+i).value
		//alert(style)
		colour = document.getElementById("colour"+i).value
		//alert(colour)
		theimage = document.getElementById("theimage"+i).value
		
		var thearraystring
		thearraystring=""
		for(j=0; j<document.frm1.sporttype.length; j++)
		{
			if(document.frm1.sporttype[j].checked==true)
			{
				thearraystring = thearraystring + document.frm1.sporttype[j].value + ";"
			//alert(document.frm1.lookalikelist[i].value)
			}
		}
		
		
		
		if(imagetype=='none')
		{
			document.getElementById("complete"+i).style.display='none'
			document.getElementById("imageverify").style.display='none'
			document.getElementById("imageverifyt").style.display='none'
		}
		//alert(imagetype)
		//Validation//
		if(garmenttype=='0')
		{
			alert('Please select a garment type in following row: '+i)
			document.getElementById("garmenttypetd"+i).style.backgroundColor='#FFD60B'
			document.getElementById("garmenttype"+i).focus()
			return false;
		}
		else
		{
			document.getElementById("garmenttypetd"+i).style.backgroundColor='#000000'
		}
		if(style=='0')
		{
			alert('Please select a style name in following row: '+i)
			document.getElementById("styletd"+i).style.backgroundColor='#FFD60B'
			document.getElementById("style"+i).focus()
			return false;
			
		}
		else
		{
			document.getElementById("styletd"+i).style.backgroundColor='#000000'
		}
		if(colour=='0')
		{
			alert('Please select a colour name in following row: '+i)
			document.getElementById("colourtd"+i).style.backgroundColor='#FFD60B'
			document.getElementById("colour"+i).focus()
			return false;
			
		}
		else
		{
			document.getElementById("colourtd"+i).style.backgroundColor='#000000'
		}
		if(theimage=='')
		{
			alert('Please select an image name in following row: '+i)
			document.getElementById("theimagetd"+i).style.backgroundColor='#FFD60B'
			document.getElementById("theimage"+i).focus()
			return false;
			
		}
		else
		{
			document.getElementById("theimagetd"+i).style.backgroundColor='#000000'
		}
		if(thearraystring=='')
		{
			alert('Please select a sport this garment is used for!')
			document.getElementById("sporttype").focus()
			return false;
		}
		
		
		
		//Next thing to do is check images are being uploaded!
		//Check correct files are being uploaded
		var iLen1 = String(document.getElementById("theimage"+i).value).length;
		var ext1 = String(document.getElementById("theimage"+i).value).substring(iLen1, iLen1 - 3);
		if (ext1.toLowerCase()  == "gif" || ext1.toLowerCase() == "jpg" || ext1.toLowerCase() == "png")
		{
			//Good
		}
			else
		{
			alert ('Please provide a correct file format for file 1 (i.e. - jpg,gif,png) in following row: '+i)
			document.getElementById("theimagetd"+i).style.backgroundColor='#FFD60B'
			document.getElementById("theimage"+i).focus()
			return false;
		}
	//Tick Boxes
	document.getElementById("complete"+i).style.display=''
	} //Loop
	
	if(imagetype=='none')
	{
		//Show image checking part
		document.getElementById("imageverify").style.display=''
		document.getElementById("imageverifyt").style.display=''
		document.getElementById("errorupload").style.display='none'
		document.getElementById("imageverifyt").innerHTML='Please wait whilst images are checked'
	}
	
	//Now replace the image name with a more conventional name
	//var newimagename = garmenttype + '_' + style + '_' + 
	//ext1
	document.getElementById("thesports").value=thearraystring
	document.frm1.submit()
	
}
function updateimageURL(num,NumberofComponents,thisvalue)
{
	document.getElementById("theimageURL"+num).value=document.getElementById("theimage"+num).value
}

function shownewimage(num,thetype)
{
	
	if (thetype=='component')
	{
	window.open ("ImageUpload/accessory_newimage.asp?imagetype="+thetype+"&imageid="+num,"ImageUpload","location=1,resizable,status=1,scrollbars=1, width=1000,height=300");
	}
	if (thetype=='garment')
	{
	window.open ("ImageUpload/garment_newimage.asp?imagetype="+thetype+"&imageid="+num,"ImageUpload","location=1,resizable,status=1,scrollbars=1, width=1000,height=300");
	}
	
}
function finishimageupload(imageid,thefilename)
{
	//alert(imageid)
	//alert(thefilename)
	window.opener.document.getElementById("theimage"+imageid).value=thefilename
	window.close()
	
}
function showuploadedimages(num,showuploadedimages)
{
	if (showuploadedimages=='component')
	{
	window.open ("ImageUpload/accessory_listimages.asp?imageid="+num,"ImageList","location=1,resizable,status=1,scrollbars=0, width=1100,height=500");	
	}
	if (showuploadedimages=='garment')
	{
	window.open ("ImageUpload/garment_listimages.asp?imageid="+num,"ImageList","location=1,resizable,status=1,scrollbars=0, width=1100,height=500");	
	}
}
function swapimage(Thefilename,FolderName,AdminImagesPath,subfolder)
{
	if(subfolder =='component')
	{
	//alert(escape(ComponentThefilename))
		document.getElementById("theimage").innerHTML= "<img src="+AdminImagesPath+"/"+escape(FolderName)+"/"+escape(Thefilename)+">"
	}
	if(subfolder =='main')
	{
		document.getElementById("theimage").innerHTML= "<img src="+AdminImagesPath+"/"+escape(FolderName)+"/"+escape(Thefilename)+">"
	}
	
}
function changebackground(thecolour)
{
	document.getElementById("rightcolumn").style.background  = thecolour	
}
function deletethisimage(Thefilename,FolderName,subfolder)
{
	var answer = confirm("Are you sure you want to delete this image?? (this cannot be undone unless you upload the image again)")
	if (answer)
	{
		frames['hidden'].location.href = "/client/MKKSports/admin/ImageUpload/delete_images.asp?Thefilename="+escape(Thefilename)+"&FolderName="+escape(FolderName)+"&subfolder="+subfolder
	}	
}
function useimage(ComponentThefilename,imageid)
{
		window.opener.document.getElementById("theimage"+imageid).value=ComponentThefilename
		window.close()
}
function updateaccessoryupload(AccessoryID)
{
		var style = document.getElementById("style"+AccessoryID).value
		var position = document.getElementById("position"+AccessoryID).value
		var accessory = document.getElementById("accessory"+AccessoryID).value
		var colour = document.getElementById("colour"+AccessoryID).value
		var theimage = document.getElementById("theimage"+AccessoryID).value
		var accessorydefault = document.getElementById("accessorydefault"+AccessoryID).value
		
		//Validation//
		if(style=='0')
		{
			alert('Please select a style name')
			document.getElementById("style"+AccessoryID).focus()
			return false;
			
		}
		if(position=='0')
		{
			alert('Please select a position name')
			document.getElementById("position"+AccessoryID).focus()
			return false;
			
		}
		if(accessory=='0')
		{
			alert('Please select an accessory name')
			document.getElementById("accessory"+AccessoryID).focus()
			return false;
			
		}
		if(colour=='0')
		{
			alert('Please select a colour name')
			document.getElementById("colour"+AccessoryID).focus()
			return false;
			
		}
		if(theimage=='')
		{
			alert('Please select an image name')
			document.getElementById("theimage"+AccessoryID).focus()
			return false;
			
		}
		//Next thing to do is check images are being uploaded!
		//Check correct files are being uploaded
		var iLen1 = String(document.getElementById("theimage"+AccessoryID).value).length;
		var ext1 = String(document.getElementById("theimage"+AccessoryID).value).substring(iLen1, iLen1 - 3);
		if (ext1.toLowerCase()  == "gif" || ext1.toLowerCase() == "jpg" || ext1.toLowerCase() == "png")
		{
			//Good
		}
			else
		{
			alert ('Please provide a correct file format for file 1 (i.e. - jpg,gif,png)')
			document.getElementById("theimage"+AccessoryID).focus()
			return false;
		}
	//Tick Boxes

	frames['hidden'].location.href = "/client/MKKSports/db/updateaccessoryuploads.asp?AccessoryID="+AccessoryID+"&style="+style+"&position="+position+"&accessory="+accessory+"&colour="+colour+"&theimage="+theimage+"&action=none&accessorydefault="+accessorydefault
}

function enableaccessoryupload(AccessoryID)
{
	var answer = confirm("Are you sure you want to enable this Uploaded Accessory?")
	if (answer)
	{
	frames['hidden'].location.href = "/client/MKKSports/db/updateaccessoryuploads.asp?AccessoryID="+AccessoryID+"&action=enable"
	}
}
function disableaccessoryupload(AccessoryID)
{
	var answer = confirm("Are you sure you want to disable this Uploaded Accessory?")
	if (answer)
	{
	frames['hidden'].location.href = "/client/MKKSports/db/updateaccessoryuploads.asp?AccessoryID="+AccessoryID+"&action=disable"
	}
}

function checkaccessory(accessoryID)
{
	if(document.getElementById("accessory"+accessoryID).value=='10')
	{
		document.getElementById("style"+accessoryID).disabled=true
		document.getElementById("position"+accessoryID).disabled=true
	}
	else
	{
		document.getElementById("style"+accessoryID).disabled=false
		document.getElementById("position"+accessoryID).disabled=false		
	}
}
function reloadpage()
{
	document.location=document.location
}
function confirmonoff(selectedval,accesslevel)
{
	
	if(accesslevel<3)
	{
		alert('Your access Level is to low to perform this action!.\n This can only be done with person with a Level 3 or above access')	
		return false;
	}
	
	if(selectedval==0)
	{
		var answer = confirm("Are you sure you wish to turn off the site? (This will prevent clients from using the online designer)")
		if (answer)
			{
				document.location = '../db/switchOnOff.asp?action=0'
			}
		else
			{
				return false;
			}
	}
	else
	{
			var answer = confirm("Are you sure you wish to turn on the site? (This will allow clients to use the online designer)")
		if (answer)
			{
				document.location = '../db/switchOnOff.asp?action=1'
			}
		else
			{
				return false;
			}
	}
	
}

function viewaffiliates()
{
	document.location = 'affiliates.asp'	
}

function StartNavigation()
{
	
	//slide_effect_close.start();
	//playSound(1)
	document.getElementById('pleasewait').style.display=''
	setTimeout ('showwait()', 3000)

}
function hidescollbar()
{
	document.body.style.overflow="hidden";
	document.body.style.overflow="visible";
}
function showwait()
{
	//slide_effect_open.start();
	$('#slide1').hide("slow")
	setTimeout ('showmain()', 1000)
}
function showmain()
{
	//alert(document.getElementById('introrefnum').value)
	//var introrefnum = document.getElementById('introrefnum').value
	document.location = 'designer.asp'
	//alert(2)
}

function setpreview(garmentid,garmenttypeid)
{
	var answer = confirm("Are you sure you want to set this garment as a preview garment for the website?")
	if (answer)
	{
		frames['hidden'].location.href = "/client/MKKSports/db/updategarments.asp?garmentid="+garmentid+"&garmenttype="+garmenttypeid+"&action=preview"
	}	
		
}
function unsetpreview(garmentid,garmenttypeid)
{
	var answer = confirm("Are you sure you want to not set this garment as a preview garment for the website?")
	if (answer)
	{
		frames['hidden'].location.href = "/client/MKKSports/db/updategarments.asp?garmentid="+garmentid+"&garmenttype="+garmenttypeid+"&action=unpreview"
	}	
		
}

function showgarmenttype(garmenttype,garmentid)
{
	
	document.getElementById(garmenttype).style.display=''
	//Change bottom Frame Images
	frames['garmentlist'].location.href = "garmentlistIFRAME.asp?garmentid="+garmentid
}

function assist(thearea,thetext)
{
	var theaction
	if(thearea=='main')
	{
		
		theaction = function() 
		{ 
			$('#tooltip').html('<font color=#FFFFFF><b>'+thetext+'</b></font>')
			//$('#tooltip').show("slow")
		}
		setTimeout(theaction, 0);
	}
	if(thearea=='frame')
	{
		theaction = function() 
		{ 
			//frames['componentlist'].document.getElementById("assistant").innerHTML=thetext; 
		}
		setTimeout(theaction, 400);
	}
}

function unassist(thearea)
{
	var theaction
	if(thearea=='main')
	{
		theaction = function() 
		{ 
			//$('#tooltip').html('')
			//$('#tooltip').hide("slow") 
		}
		setTimeout(theaction, 0);
	}
	if(thearea=='parent')
	{
		theaction = function() 
		{ 
			//frames['componentlist'].document.getElementById("assistant").innerHTML=thetext; 
		}
		setTimeout(theaction, 10000);
	}
}

//Function to replicate the same in the component drop down list
function replicateall(dropdownlistsection,numcomponents)
{
		var i
		for (i=2; i <=numcomponents ; i++)
			{	
				document.getElementById(dropdownlistsection+i).value=document.getElementById(dropdownlistsection+1).value
			}
}

function showcarousel(garmenttype,garmentid,target,thesports)
{
	
	if(target=='main')
	{
		
		document.getElementById("previousgarment").style.display='none'
		document.getElementById("frontback").style.display='none'
		document.getElementById("innerbuttons").style.display='none'
		document.getElementById("norefnum").style.display='none'
		
		//$('#previousgarment').hide("fast")
		//$('#frontback').hide("fast")
		//$('#innerbuttons').hide("fast")
		//$('#norefnum').hide("fast")
		//Flush Garment incase they choose something different
		
		FlushGarment("main")
		hideallshadows()
		document.getElementById("maincontainer").style.display='none'
		//$('#maincontainer').hide("fast")
		
		document.getElementById("introductorycontainer").style.display="none"
		
		//$('#carousellist').show("fast")
		document.getElementById("carousellist").style.display=""
		$('#carousellist').attr('src',"/client/MKKSports/Main/includes/carousellist.asp?style="+garmenttype+"&garmentid="+garmentid+"&sportid="+thesports); 
		
		frames['componentlist'].location.href = "/client/MKKSports/Main/rightpanelIFRAME.asp?style="
	}
	if(target=='parent')
	{
		parent.document.getElementById("previousgarment").style.display='none'
		parent.document.getElementById("frontback").style.display='none'
		parent.document.getElementById("innerbuttons").style.display='none'
		FlushGarment("frames")
		parent.document.getElementById("maincontainer").style.display='none'
		parent.document.getElementById("introductorycontainer").style.display="none"
		parent.document.getElementById("carousellist").style.display=""
		parent.frames['carousellist'].location.href= "/client/MKKSports/Main/includes/carousellist.asp?style="+garmenttype+"&garmentid="+garmentid+"&sportid="+thesports
		parent.frames['componentlist'].location.href = "/client/MKKSports/Main/rightpanelIFRAME.asp?style="
		
		
	}
	if(target=='main')
	{
		document.getElementById("carousellist").style.display=""
		document.getElementById("previousgarment").style.display='none'
		document.getElementById("frontback").style.display='none'
		document.getElementById("innerbuttons").style.display='none'
		FlushGarment("main")
		document.getElementById("maincontainer").style.display='none'
		document.getElementById("introductorycontainer").style.display="none"
		document.getElementById("carousellist").style.display=""
		frames['carousellist'].location.href= "/client/MKKSports/Main/includes/carousellist.asp?style="+garmenttype+"&garmentid="+garmentid+"&sportid="+thesports
		frames['componentlist'].location.href = "/client/MKKSports/Main/rightpanelIFRAME.asp?style="
		
		
	}
}

function showstyleheader(stylename)
{
	document.getElementById("garmentheader").innerHTML='You are now viewing the '+stylename+' style&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
	document.getElementById("chosenstyle").value=stylename
	
}

function begingarmentdesign(stylename,garmentid,sportsid)
{
	
	get_lastestimages()
	//Hide Elements
	if(document.getElementById("tooltip"))
	{
		document.getElementById("tooltip").style.display='none'
	}
	
	//$('#tooltip').hide("fast")
	if(document.getElementById("selectheading"))
	{
		document.getElementById("selectheading").style.display='none'
	}
	if(document.getElementById("selectheading"))
	{
		document.getElementById("garmentlist").style.display='none'
	}
	//$("#selectheading").hide("slow")
	//document.getElementById("garmentlist").style.display='none'
	//$("#garmentlist").hide("slow")
	
	
	parent.frames['garmentlist'].document.getElementById("container-1").style.display=''
	parent.frames['garmentlist'].document.getElementById("selectedstyle").value=stylename
	parent.frames['garmentlist'].document.getElementById("selectedgarment").value=garmentid
	parent.frames['garmentlist'].document.getElementById("selectedsport").value=sportsid
	parent.frames['componentlist'].location.href = "/client/MKKSports/Main/rightpanelIFRAME.asp?style="+stylename+"&garmentid="+garmentid+"&sportsid="+sportsid
	parent.document.getElementById("carousellist").style.display="none"
  	
	parent.document.getElementById("thestyle").value=stylename
	parent.document.getElementById("garmentid").value=garmentid
	//alert(sportsid)
	parent.document.getElementById("sportid").value=sportsid
	//setTimeout ("AJAXcheckSession('pullsession','"+garmentid+"','"+stylename+"')", 100 );
	
	AJAXcheckSession('pullsession',garmentid,stylename,sportsid);
    
	//monitor user click
    setTimeout ("AJAXUpdateSessionClick('"+stylename+"','"+garmentid+"','"+sportsid+"')", 1500 ); //Poxy bug to clear one more step

	
	
	
  
}


function doswitch(divtag,foldername,imageurl,GarmentName,GarmentID,thestyle,thecolour,theaction,thesportid)
{
    
	if(divtag=='main')
	{
		 
		 parent.document.getElementById("badges").style.display=""
		 if(document.getElementById("mainselected"))
		 {
			 document.getElementById("mainselected").value=1
			
		 }
	
	get_dynamiccollars(thecolour,thestyle,GarmentName,theaction,GarmentID,thesportid)
		
	parent.document.getElementById("maingarmentcolour").value=thecolour
	//alert(thecolour)
	//alert(thestyle)
	//get_dynamiccollars(thecolour,thestyle)

	}

		//case "maincontainer1" :
		    if (divtag =='clear')
		    {
		        parent.document.getElementById(foldername).innerHTML=""
		    }
		    else
		    {
		         if(document.getElementById("mainselected"))
		 		{
			 		if(document.getElementById("mainselected").value==0)
					{
						changeimage()
						alert('Please select a base garment first before selecting your accessories')
						parent.document.getElementById("frontback").style.display="none"
						parent.document.getElementById("innerbuttons").style.display="none"
   						parent.document.getElementById("maincontainer").style.display="none"
						parent.document.getElementById("introductorycontainer").style.display=""
						return false;
					}
		 		}
				//alert("<img src='/client/MKKSports/images/admin/"+foldername+"/"+imageurl+"'>")
				//alert(GarmentID)
				parent.document.getElementById(foldername).innerHTML="<img src='/client/MKKSports/images/admin/"+foldername+"/"+imageurl+"'>"
				//alert("<img src='/client/MKKSports/images/admin/"+foldername+"/"+imageurl+"'>")
		    }
		 
	//alert(parent.document.getElementById("maincontainer").innerHTML)
	
   AJAXUpdateSession('updatesession',divtag,GarmentName,GarmentID,foldername,imageurl,thestyle,thecolour,thesportid);
  
  
  //setTimeout ("AJAXUpdateSessionClick('"+stylename+"','"+garmentid+"')", 1500 ); 
  
  
  //Capture HTML
   setTimeout ("capturescreen('"+GarmentID+"','"+thestyle+"','"+GarmentName+"')", 250 ); 
 	//alert(GarmentName)
 // parent.frames['hidden'].location.href = "/client/MKKSports/Main/Includes/capturescreen.asp?theGarmentID="+GarmentID+"&theStyle="+thestyle+"&FolderName="+foldername
}
function capturescreen(GarmentID,thestyle,GarmentName)
{
	parent.document.getElementById('CaptureGarmentID').value=GarmentID
	parent.document.getElementById('CaptureStyle').value=thestyle
	parent.document.getElementById('CaptureGarmentName').value=GarmentName
	parent.document.getElementById('CaptureHTML').value=parent.document.getElementById('screenshot').innerHTML
	
	//alert(parent.document.getElementById('screenshot').innerHTML)
	
	
	parent.document.frmtemp.submit()

}
   

function changeimage()
{
	document.getElementById("themainsection").style.backgroundImage ='url(/client/MKKSports/images/main/animatedtitlebar.gif)';

}
function unchangeimage()
{
	document.getElementById("themainsection").style.backgroundImage ='url(/client/MKKSports/images/main/titlebar.png)';

}
function hideallshadows()
{
	
	//Accommodate for up to 25 garments
	var i
	for (i=0; i <=25 ; i++)
	{
		if(document.getElementById("shadow"+i))
		{
			document.getElementById("shadow"+i).style.display="none"
		}
	}
}


function switchdesign(divtag,GarmentName,GarmentID,foldername,imageurl,thestyle,thecolour,theaction,thesportid)
{
	
   //onclick=""switchdesign('','"&GarmentType&"',"&CollarID&",'"&foldername&"','"&CollarURL&"','"&thestyle&"')""
    //debugr(divtag,GarmentName,GarmentID,foldername,imageurl)

	parent.document.getElementById("carousellist").style.display="none"
	//alert(2)
	//parent.document.getElementById("maincontainer").style.display="none"
	if(document.getElementById('ajaxcalled'))
	{
	    document.getElementById('ajaxcalled').value=0 //Reset the fact no Ajax Call has been done yet
	}
	
	parent.document.getElementById("introductorycontainer").style.display="none"
	
	var themaingarmentid = parent.document.getElementById("garmentid").value
	
	divtag=divtag.toLowerCase();
	
	GarmentName = GarmentName.toLowerCase();
	
	
	//SetPostionDetails(divtag,GarmentName) //Getting  and setting the position for this garment to be accurately placed on the page
	
	
	if(parent.document.getElementById("shadow"+themaingarmentid))
	{
		parent.document.getElementById("shadow"+themaingarmentid).style.display=""
	}
	parent.document.getElementById("maincontainer").style.display=""
	parent.document.getElementById("frontback").style.display=""
	parent.document.getElementById("innerbuttons").style.display=""

    
	
    setTimeout ("doswitch('"+divtag+"','"+foldername+"','"+imageurl+"','"+GarmentName+"','"+GarmentID+"','"+thestyle+"','"+thecolour+"','"+theaction+"','"+thesportid+"')", 400 ); 
	
}


function AJAXUpdateSessionClick(thestyle,garmentid,sportid)
{
	
	parent.frames['hidden'].location.href = "/client/MKKSports/Main/Includes/updateclick.asp?stylename="+thestyle+"&garmentid="+garmentid+"&sportid="+sportid
}

function pausecomp(millis) 
{
    // alert('hi')
    var date = new Date();
    var curDate = null;

    do { curDate = new Date(); } 
    while(curDate-date < millis);
} 



function SetPostionDetails(divtag,GarmentName)
{ 
	
	
	var url="/client/MKKSports/Main/Includes/getposition.asp?divtag="+divtag+"&GarmentName="+GarmentName;
	//var inputone = prompt("Debug",url);
	xmlHttp=GetXmlHttpObject(stateChanged);
	xmlHttp.open("GET", url , true);
	xmlHttp.send(null);
}

function stateChanged() 
{
   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
      var theresponse = xmlHttp.responseText
     
      var mySplitResult = theresponse.split(";");
      
      var divid =  mySplitResult[0]
      //alert('div id is '+divid)
      var garmentname =  mySplitResult[1]
      //alert('garmentname is '+garmentname)
      var divtag =  mySplitResult[2]+'_'+mySplitResult[3]
      //alert('divtag  is '+divtag)
      var style =  mySplitResult[4]+';'+mySplitResult[5]+';'+mySplitResult[6]+';'+mySplitResult[7]
      //alert('style  is '+style)
    
      
      //Postion the element now
     parent.document.getElementById(divid).innerHTML="<div name='"+divtag.toLowerCase()+"' id='"+divtag.toLowerCase()+"' style='"+style.toLowerCase()+"'></div>"
     //now set the flag to say the AJAX call is done
     //document.getElementById('ajaxcalled').value=1
     //alert(parent.document.getElementById(divid).innerHTML)
   }
} 
function AJAXcheckSession(theaction,maingarmentid,stylename,sportsid)
{
   var url="/client/MKKSports/Main/Includes/update.asp?theaction="+theaction+"&maingarmentid="+maingarmentid+'&stylename='+stylename+'&sportsid='+sportsid
  // var inputone = prompt("Debug",url);
   
   xmlHttp=GetXmlHttpObject(AJAXCall);
   xmlHttp.open("GET", url , true);
   xmlHttp.send(null);
}

function AJAXUpdateSession(theaction,divtag,GarmentName,GarmentID,foldername,imageurl,thestyle,thecolour,thesportid)
{
  
   thecolour = thecolour.replace("#","")
   var url="/client/MKKSports/Main/Includes/update.asp?theaction="+theaction+"&divtag="+divtag+"&GarmentName="+GarmentName+"&GarmentID="+GarmentID+"&foldername="+foldername+"&imageurl="+imageurl+"&stylename="+thestyle+"&thecolour="+thecolour+"&sportsid="+thesportid
   //var inputone = prompt("Debug",url);
   xmlHttp=GetXmlHttpObject(AJAXCall);
   xmlHttp.open("GET", url , true);
   xmlHttp.send(null);  
}

function AJAXCall()
{
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
         var theresponse = xmlHttp.responseText
       //alert(theresponse)
         if(parent.document.getElementById("introductorycontainer"))
         {
             if (theresponse ==0)
             {
             parent.document.getElementById("introductorycontainer").style.display=""
             }
             if (theresponse ==1) //Meaning they have got a style already linked to them
             {
                //Automatically populate the garment with there last used Garment
               var stylename
               stylename = parent.frames['garmentlist'].document.getElementById("selectedstyle").value
			   var maingarmentid
               maingarmentid = parent.frames['garmentlist'].document.getElementById("selectedgarment").value
			   var selectedsport
			   selectedsport = parent.frames['garmentlist'].document.getElementById("selectedsport").value
               //alert(stylename)
               setTimeout ("getpreviousgarment('getgarment','"+stylename+"','"+maingarmentid+"','"+selectedsport+"')", 400 );
              }
             if (theresponse.indexOf("|") > 0)
             {
                
                //alert(theresponse)
                
                var mySplitResult = theresponse.split("|"); 
				//alert(mySplitResult)
				// main_main;shirts;2;SHIRTS;SHIRTS_PLAIN_BLACK.png;ANGEL
                                                            // panels_flank;shirts;134;PANELS;ANGEL_FLANK_PANELS_WHITE.png;ANGEL
                                                            // panels_shoulder;shirts;105;PANELS;ANGEL_SHOULDER_PANELS_WHITE.png;ANGEL
                                                            //collars_collars;shirts;178;COLLARS;ANGEL_COLLAR_BRITISH_WHITE.png;ANGEL
                                                            // Above is a length of 5            
                //var inputone = prompt("Debug",mySplitResult);
                //alert(mySplitResult.length) // 5
                var mySplitResulttoPass,j
               	
                for (i=0 ; i < (mySplitResult.length)-1; i++)
                {
                       mySplitResulttoPass = mySplitResult[i].split(";")
                       
                       switchdesign(mySplitResulttoPass[0],mySplitResulttoPass[1],mySplitResulttoPass[2],mySplitResulttoPass[3],mySplitResulttoPass[4],mySplitResulttoPass[5],mySplitResulttoPass[6],'pull',mySplitResulttoPass[7])
					   parent.frames['componentlist'].document.getElementById("mainselected").value=1
                       //alert('done')
                }
              	
			  parent.document.getElementById('previousgarment').style.display=''
              
             }
          }
          if (theresponse ==7)
          {
              parent.frames['hidden'].location.href = "/client/MKKSports/Main/Includes/flush.asp?theaction=restart"
              
          }
    }
}
function FlushGarment(thearea)
{
    switch(thearea)
	{
		
		case "main":
			frames['hidden'].location.href = "/client/MKKSports/Main/Includes/flush.asp"
		break;
		case "frames":
			parent.frames['hidden'].location.href = "/client/MKKSports/Main/Includes/flush.asp"
			
		break;
	}


      
}
function FlushBadges()
{
    
    frames['hidden'].location.href = "/client/MKKSports/Main/Includes/flush.asp?theaction=badges"
      
}

function getpreviousgarment(theaction,thestyle,themaingarmentid,sportsid)
{
    
    
    setTimeout ("AJAXShowDesignedGarment('getgarment','"+thestyle+"','"+themaingarmentid+"','"+sportsid+"')", 600 );
}




function AJAXShowDesignedGarment(theaction,thestyle,maingarmentid,sportsid)
{
   //var url="/client/MKKSports/Main/Includes/getlastgarment.asp?theaction="+theaction+"&stylename="+thestyle
   var url="/client/MKKSports/Main/Includes/update.asp?theaction="+theaction+"&stylename="+thestyle+"&maingarmentid="+maingarmentid+"&sportsid="+sportsid
   
  // var inputone = prompt("Debug",url);
   xmlHttp=GetXmlHttpObject(AJAXCall);
   xmlHttp.open("GET", url , true);
   xmlHttp.send(null);  
}



function debugr(divtag,GarmentName,GarmentID,foldername,imageurl)
{
    alert(divtag)
     alert(GarmentName)
      alert(GarmentID)
       alert(foldername)
        alert(imageurl)
        
}
function GetXmlHttpObject(handler)
{ 
	var objXmlHttp=null;
	
	if (navigator.userAgent.indexOf("MSIE")>=0)
	{ 
		var strName="Msxml2.XMLHTTP";
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
		{
			strName="Microsoft.XMLHTTP";
		} 
		try
		{ 
			objXmlHttp=new ActiveXObject(strName);
			objXmlHttp.onreadystatechange=handler;
			return objXmlHttp;
		} 
		catch(e)
		{ 
			alert("Error. Scripting for ActiveX might be disabled");
			return;
		} 
	} 
	if (navigator.userAgent.indexOf("Mozilla")>=0)
	{
		objXmlHttp=new XMLHttpRequest();
		objXmlHttp.onload=handler;
		objXmlHttp.onerror=handler;
		return objXmlHttp;
	}
} 

function logoupload()
{
    if (document.getElementById("theimage").value=="")
    {
       alert('Please browse for an image to upload')
        document.getElementById("theimage").focus();
        return false;
        
    }
    else
    {
        document.frm1.submit()
    }
}

function removeupload(imageURL,thenum)
{
  	
  var lastselectedarea
  lastselectedarea = document.getElementById('lastselected'+thenum).value
    
   var answer = confirm("Are you sure you want to delete this uploaded image permanently?")
	if (answer)
	{
		frames['imageupload'].location.href = "includes/imageremove.asp?imageURL="+imageURL+"&lastselectedarea="+lastselectedarea+"&thenum="+thenum
	
		parent.document.getElementById(lastselectedarea).innerHTML=""
		parent.document.getElementById(lastselectedarea).style.display='none'
		
	}
}



function positionbadge(selectedarea,imageURL,theguid,thenum)
{
	
	if(parent.frames['componentlist'].document.getElementById("mainselected").value==0)
	{
		parent.frames['componentlist'].document.getElementById("themainsection").style.backgroundImage ='url(/client/MKKSports/images/main/animatedtitlebar.gif)';
		alert('Please select a base garment first before positioning your badges')
		document.getElementById("badgearealist"+thenum).value='none'
		return false;
		
	}
	var lastselectedarea     
	
	if(selectedarea=="none")
	{
		lastselectedarea = document.getElementById('lastselected'+thenum).value
		parent.document.getElementById(lastselectedarea).innerHTML=""
		parent.document.getElementById(lastselectedarea).style.display='none'
		UpdateBadgeSession(selectedarea,imageURL,theguid,'removebadge',thenum)
	}
	else
	{
		if(document.getElementById('lastselected'+thenum).value !='')
		{
			lastselectedarea = document.getElementById('lastselected'+thenum).value
			parent.document.getElementById(lastselectedarea).innerHTML=''
			parent.document.getElementById(lastselectedarea).style.display='none'
		}
		//if(parent.document.getElementById(selectedarea))
		//{
		//	alert('good')	
		//}
		parent.document.getElementById(selectedarea).style.display=''
		var iLen1 = String(imageURL).length;
		var ext1 = String(imageURL).substring(iLen1, iLen1 - 3);
		if (ext1.toLowerCase()  == "gif" || ext1.toLowerCase() == "jpg" || ext1.toLowerCase() == "png" || ext1.toLowerCase() == "bmp")
		{
			parent.document.getElementById(selectedarea).innerHTML="<img src='/client/MKKSports/images/admin/clientuploads/"+theguid+"/"+imageURL+"' title='"+selectedarea+"' width='25px' height='20px'>"
		}
			else
		{
			parent.document.getElementById(selectedarea).innerHTML="<img src='/client/MKKSports/images/main/nopreview.png' title='"+selectedarea+"' width='25px' height='20px'>"
		}
		
		//alert("<img src='/client/MKKSports/images/admin/clientuploads/"+theguid+"/"+imageURL+"' title='"+selectedarea+"' width='25px' height='20px'>")
		document.getElementById('lastselected'+thenum).value=selectedarea
		UpdateBadgeSession(selectedarea,imageURL,theguid,'addbadge',thenum)
		
	}
	
	//parent.document.getElementById('CaptureGarmentID').value=GarmentID
	//parent.document.getElementById('CaptureStyle').value=thestyle
	//parent.document.getElementById('CaptureGarmentName').value=GarmentName
	//parent.document.getElementById('CaptureHTML').value=parent.document.getElementById('screenshot').innerHTML
	 setTimeout ("capturescreen('"+parent.document.getElementById('CaptureGarmentID').value+"','"+parent.document.getElementById('CaptureStyle').value+"','"+parent.document.getElementById('CaptureGarmentName').value+"')", 250 );

}

function removeallbadges()
{
	parent.document.getElementById("badges").style.display="none"
}
function UpdateBadgeSession(selectedarea,imageURL,theguid,theaction,thenum)
{
	AJAXUpdateSession(theaction,selectedarea,'','',thenum,imageURL,'thestyle','')
}

function reloadlogospage(thevalue)
{
    window.location.href  = "imageupload.asp?NumberofComponents="+thevalue
}


function verify_logoimages(numaccessories)
{
	
	var i;
	var imagename;
	var cont;
	
	for (i=1;i<=numaccessories;i++)
	{
		
		
		theimage = document.getElementById("theimage"+i).value
		
		//Validation//
		
		if(theimage=='')
		{
			alert('Please select an image name in following row: '+i)
			document.getElementById("theimagetd"+i).style.backgroundColor='#FFD60B'
			document.getElementById("theimage"+i).focus()
			return false;
		}
		else
		{
			document.getElementById("theimagetd"+i).style.backgroundColor='#000000'
		}
		
		//Next thing to do is check images are being uploaded!
		//Check correct files are being uploaded
		var iLen1 = String(document.getElementById("theimage"+i).value).length;
		var ext1 = String(document.getElementById("theimage"+i).value).substring(iLen1, iLen1 - 3);
		if (ext1.toLowerCase()  == "gif" || ext1.toLowerCase() == "jpg" || ext1.toLowerCase() == "png" || ext1.toLowerCase() == "cdr" || ext1.toLowerCase() == "pdf" || ext1.toLowerCase() == "tif" || ext1.toLowerCase() == "eps" || ext1.toLowerCase() == ".ai" || ext1.toLowerCase() == "dst")
		{
			//Good
		}
			else
		{
			alert ('Please provide a correct file format for file 1 (i.e. - jpg,gif,png) in following row: '+i)
			document.getElementById("theimagetd"+i).style.backgroundColor='#FFD60B'
			document.getElementById("theimage"+i).focus()
			return false;
		}
	
	}
	$('#uploadgif').hide("slow")
	$('#waitgif').show("slow")
	document.frm1.submit()

}

function startagain(thestyle,thegarmentid,sportsid)
{
   
	
	
	var answer = confirm("Are you sure you want to clear your current design?")
	if (answer)
	{
	    
	    
		AJAXUpdateSession('startagain','divtag','GarmentName',thegarmentid,'foldername','imageurl',thestyle,'',sportsid)
		removeallbadges()
		frames['componentlist'].document.getElementById("mainselected").value=0
		if(document.getElementById("previousgarment"))
		{
			document.getElementById("previousgarment").style.display='none'
		}
		
		if(document.getElementById("shadow"+thegarmentid))
		{
			document.getElementById("shadow"+thegarmentid).style.display='none'
		}
		
		
		//previousgarment
		//ddaccordion.collapseall('expandable');
		//return false
	}
    
    
}

function get_lastestimages()
{
	 
	//alert(5656)
	var url="/client/MKKSports/Main/Includes/getuploadedimages.asp"
   //var url="/client/MKKSports/Main/Includes/update.asp?theaction="+theaction+"&stylename="+thestyle
   //var inputone = prompt("Debug",url);
   xmlHttp=GetXmlHttpObject(ImageAJAXCall);
   xmlHttp.open("GET", url , true);
   xmlHttp.send(null); 
}
function ImageAJAXCall()
{
	 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
         var theresponse = xmlHttp.responseText
		  
		  if(parent.document.getElementById('uploadedarea'))
		  {
		  	
			parent.document.getElementById('uploadedarea').innerHTML=theresponse
		  }
		 // alert(1)
		  
     	
	}
}

function get_dynamiccollars(theColour,thestyle,GarmentType,theaction,GarmentID,thesportid)
{
		  //alert(GarmentType.toLowerCase())
		  if(GarmentType.toLowerCase()=="shirts" || GarmentType.toLowerCase()=="tri-band slipover" || GarmentType.toLowerCase()=="technical cricket trousers" || GarmentType.toLowerCase()=="shorts" || GarmentType.toLowerCase()=="skorts" || GarmentType.toLowerCase()=="slipover" || GarmentType.toLowerCase()=="tracksuit trousers" || GarmentType.toLowerCase()=="tracksuit jackets")
		  {
		   theColour = theColour.replace("#","")
		  setTimeout ("get_dynamiccollarsDO('"+theColour+"','"+thestyle+"','"+GarmentType+"','"+theaction+"','"+thesportid+"')", 1000 ); //Poxy bug to clear one more step
		  }
}

function get_dynamiccollarsDO(theColour,thestyle,GarmentType,theaction,thesportid)
{

	var url="/client/MKKSports/Main/Includes/attachedcollars.asp?theColour="+theColour+"&thestyle="+thestyle+"&GarmentType="+GarmentType+"&theaction="+theaction+"&thesportid="+thesportid
   //var inputone = prompt("Debug",url);
   xmlHttp=GetXmlHttpObject(CollarsAJAXCall);
   xmlHttp.open("GET", url , true);
   xmlHttp.send(null); 
}
function CollarsAJAXCall()
{
	var DefaultCollarID,Defaultfoldername,DefaultCollarURL,DefaultCollarColourHex
	var DefaultGarmentType,DefaultStyle,theAction,DefaultCollarSportID
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
         var theresponse = xmlHttp.responseText
		 
		 
		 if(parent.document.getElementById('dyncollars'))
		  {
		  	parent.document.getElementById('dyncollars').innerHTML=theresponse
			//put on default attached accessory
			 DefaultCollarID=parent.document.getElementById('DefaultCollarID').value
			  Defaultfoldername =parent.document.getElementById('Defaultfoldername').value
			  DefaultCollarURL = parent.document.getElementById('DefaultCollarURL').value
			  DefaultCollarColourHex = parent.document.getElementById('DefaultCollarColourHex').value
			  DefaultGarmentType = parent.document.getElementById('DefaultGarmentType').value
			  DefaultStyle = parent.document.getElementById('DefaultStyle').value
			  //alert(theAction)
			  theAction = parent.document.getElementById('theAction').value
			  DefaultCollarSportID =parent.document.getElementById('DefaultCollarSportID').value
			 //switchdesign('',DefaultGarmentType,DefaultCollarID,Defaultfoldername,DefaultCollarURL,DefaultStyle,DefaultCollarColourHex)	
		  }
		  
		if(parent.frames['componentlist'].document.getElementById("dyncollars"))
		  {
			  
			  parent.frames['componentlist'].document.getElementById('dyncollars').innerHTML=theresponse
			  DefaultCollarID=parent.frames['componentlist'].document.getElementById('DefaultCollarID').value
			  //alert(DefaultCollarID)
			  Defaultfoldername = parent.frames['componentlist'].document.getElementById('Defaultfoldername').value
			  DefaultCollarURL = parent.frames['componentlist'].document.getElementById('DefaultCollarURL').value
			  DefaultCollarColourHex = parent.frames['componentlist'].document.getElementById('DefaultCollarColourHex').value
			  DefaultGarmentType = parent.frames['componentlist'].document.getElementById('DefaultGarmentType').value
			  DefaultStyle = parent.frames['componentlist'].document.getElementById('DefaultStyle').value
			  
			   
			  theAction  = parent.frames['componentlist'].document.getElementById('theAction').value
			  DefaultCollarSportID  = parent.frames['componentlist'].document.getElementById('DefaultCollarSportID').value
			 //alert(theAction)
			  if(theAction!='pull')
			  {
			  //alert(DefaultCollarSportID)
			  switchdesign('',DefaultGarmentType,DefaultCollarID,Defaultfoldername,DefaultCollarURL,DefaultStyle,DefaultCollarColourHex,'put',DefaultCollarSportID)
			  }
			  
			  
		  }
		  
     	
	}
}


function contquote()
{
	var numofselections,garmentbuild,mywindow
	garmentbuild = ""
	numofselections = document.getElementById('numselections').value
	for (i=0 ; i < (numofselections); i++)
	{
		garmentbuild = garmentbuild + document.getElementById('garmentquote'+i).value + ";"
		//alert(document.getElementById('garmentquote'+i).value)
	}
	
	mywindow = window.open ("quoteform.asp?itemselected="+garmentbuild,"mywindow","location=1,status=0,toolbar=no, menubar=no, scrollbars=yes,addressbar=no,width=1100,height=600");
 
}
function expandaccessories(garmenttype,garmentstyle)
{
	document.getElementById('accessorieslist_'+garmenttype+'_'+garmentstyle).style.display=''
					
}
function collapseaccessories(garmenttype,garmentstyle)
{
	document.getElementById('accessorieslist_'+garmenttype+'_'+garmentstyle).style.display='none'
}

function sendquote()
{
	
	var cycle,qty,cont
	cont=1
	cycle= document.getElementById('cycle').value
	var firstname,lastname,telnum,email,additionalcommments,organisation
	
	for (i=0 ; i <= (cycle); i++)
	{
		document.getElementById("qtytd"+i).style.backgroundColor='#0B0602'
		qty = document.getElementById('qty'+i).value
		if(qty==0)
		{
			document.getElementById("qtytd"+i).style.backgroundColor='#FFD60B'
			//border-bottom: #4A75AC solid 1px;
			alert('Please enter a quantity for for the highlight area. All quantities must be greater than 0')
			cont = 0
			break;
		}
		else
		{
			document.getElementById("qtytd"+i).style.backgroundColor='#0B0602'
		}
	}
	firstname=document.getElementById('firstname').value
	lastname=document.getElementById('lastname').value
	telnum=document.getElementById('telnum').value
	email=document.getElementById('email').value
	organisation = document.getElementById('organisation').value
	additionalcommments=document.getElementById('additionalcommments').value
	if (cont==1)
	{
		if(firstname=='')
		{
			alert('Please enter your first name')
			document.getElementById('firstname').focus()
			cont = 0
			return false;
		}
		if(lastname=='')
		{
			alert('Please enter your last name')
			document.getElementById('lastname').focus()
			cont = 0
			return false;
		}
		
		if(email=='')
		{
			alert('Please enter your email address')
			document.getElementById('email').focus()
			cont = 0
			return false;
		}
		if(organisation=='')
		{
			alert('Please enter your organisations name')
			document.getElementById('organisation').focus()
			cont = 0
			return false;
		}
		if(echeck(email))
		{
		}
		else
		{
				cont=0
		}
		
	}
if(cont==1)
{
	//document.getElementById('action').value='send'
	document.frm1.submit()
}


}
function showhidereturn()
{
	for (i=0;i<document.frmreturn.yesno.length;i++) 
	{ 
      if (document.frmreturn.yesno[i].checked) 
      { 
             var selectedvalue = document.frmreturn.yesno[i].value; 
     } 
}
	
	//alert(document.getElementById('yesno').value)
	
	if (selectedvalue=='yes')
	{
		$('#returningyes').show("slow")
		$('#returning1yes').show("slow")
		$('#returning2yes').show("slow")
		$('#returning3yes').show("slow")
		$('#returningno').hide("slow")
		
	}
	else
	{
		$('#returningyes').hide("slow")
		$('#returning1yes').hide("slow")
		$('#returning2yes').hide("slow")
		$('#returning3yes').hide("slow")
		$('#returningno').show("slow")
	}
}
function searchreference()
{
	var introrefnum =  document.getElementById("introrefnum").value
	if(introrefnum=='')
	{
		alert('Please enter a valid reference number')
		document.getElementById("introrefnum").focus()
		return false;
	}
	if(IsNumeric(introrefnum))
	{
		parent.document.location = "../designer.asp?introrefnum="+introrefnum
	}
	else
	{
		alert('Please enter only numbers in the reference field')
		document.getElementById("introrefnum").focus()
		return false;
	}
	
}

function editaffiliate(affiliateid)
{
	document.getElementById("userdetails_"+affiliateid).style.display=''
}
function uneditaffiliate(affiliateid)
{
	document.getElementById("userdetails_"+affiliateid).style.display='none'
}

function deleteaffiliate(theuserid,thecompanyname)

{
	//alert(thecompanyname)
	var answer = confirm("Are you sure you want to disable the account of "+thecompanyname +"?")
	if (answer)
	{
		frames['hidden'].location.href = "/client/MKKSports/db/activateaffiliate.asp?userid="+theuserid+"&action=disable"
	}	
}
function enableaffiliate(theuserid,thecompanyname)
{
	var answer = confirm("Are you sure you want to enable the account of "+thecompanyname +"?")
	if (answer)
	{
		frames['hidden'].location.href = "/client/MKKSports/db/activateaffiliate.asp?userid="+theuserid+"&action=enable"
	}	
}

function updateaffiliate(userid)
{
	
	//Validate fields first
	if(document.getElementById("firstname_"+userid).value=='')
	{
		alert('Please enter a First Name for this affiliate')
		document.getElementById("firstname_"+userid).focus()
		return false
	}
	if(document.getElementById("lastname_"+userid).value=='')
	{
		alert('Please enter a Last Name for this affiliate')
		document.getElementById("lastname_"+userid).focus()
		return false
	}
	if(document.getElementById("email_"+userid).value=='')
	{
		alert('Please enter an email address for this user (very important)')
		document.getElementById("email_"+userid).focus()
		return false
	}
	if(document.getElementById("TelephoneNumber_"+userid).value=='')
	{
		alert('Please enter a telephone number')
		document.getElementById("TelephoneNumber_"+userid).focus()
		return false
	}
	if(document.getElementById("CompanyName_"+userid).value=='')
	{
		alert('Please enter a company name')
		document.getElementById("CompanyName_"+userid).focus()
		return false
	}
	
	
	
var firstname = document.getElementById("firstname_"+userid).value
var lastname = document.getElementById("lastname_"+userid).value
var email = document.getElementById("email_"+userid).value
var TelephoneNumber = document.getElementById("TelephoneNumber_"+userid).value
var CompanyName = document.getElementById("CompanyName_"+userid).value
var thepassword


frames['hidden'].location.href = "/client/MKKSports/db/updateaffiliatedetails.asp?userid="+userid+"&firstname="+firstname+"&lastname="+lastname+"&email="+email+"&TelephoneNumber="+TelephoneNumber+"&CompanyName="+CompanyName
	
}

function newaffiliateaccount()
{
	//Validate fields first
	if(document.getElementById("newfirstname").value=='')
	{
		alert('Please enter a First Name for this affiliate')
		document.getElementById("newfirstname").focus()
		return false
	}
	if(document.getElementById("newlastname").value=='')
	{
		alert('Please enter a Last Name for this affiliate')
		document.getElementById("newlastname").focus()
		return false
	}
	if(document.getElementById("newEmail").value=='')
	{
		alert('Please enter an email address for this affiliate (very important)')
		document.getElementById("newEmail").focus()
		return false
	}
	if(document.getElementById("newTelephoneNumber").value=='')
	{
		alert('Please enter a telephone number')
		document.getElementById("newTelephoneNumber").focus()
		return false
	}
	if(document.getElementById("newCompanyName").value=='')
	{
		alert('Please enter a company name for this affiliate')
		document.getElementById("newCompanyName").focus()
		return false
	}
	
	
	if(echeck(document.getElementById("newEmail").value))
	{
		var firstname = document.getElementById("newfirstname").value
		var lastname =  document.getElementById("newlastname").value
		var email = document.getElementById("newEmail").value
		var TelephoneNumber =  document.getElementById("newTelephoneNumber").value
		var CompanyName = document.getElementById("newCompanyName").value
     	var Active = 1
		
	
	frames['hidden'].location.href = "/client/MKKSports/db/newaffiliate.asp?firstname="+firstname+"&lastname="+lastname+"&email="+email+"&TelephoneNumber="+TelephoneNumber+"&CompanyName="+CompanyName.replace("&","and")+"&active="+Active
	 }

}

function setselectedcolour(colourchosen,garmenttype,thestyle)
{
	document.getElementById("selectedcolour_"+garmenttype).value=colourchosen
	
}
function hint(whitePanelURL,whitePanelfoldername,darkerPanelURL,darkerPanelfoldername,GarmentType)
{
	var selectedbase = document.getElementById("selectedcolour_"+GarmentType).value
	var mainselected = document.getElementById("mainselected").value
	//IF white base colour show darker colour
	if(mainselected==1)
	{
		if (selectedbase=='#FFFFFF')
		{
			
			parent.document.getElementById("blackhint_"+darkerPanelfoldername).innerHTML = "<img src='/client/MKKSports/images/admin/"+darkerPanelfoldername+"/"+darkerPanelURL+"'>"
			parent.document.getElementById("blackhint_"+darkerPanelfoldername).style.display=""
		}
		else
		{
			
			parent.document.getElementById("whitehint_"+whitePanelfoldername).innerHTML = "<img src='/client/MKKSports/images/admin/"+whitePanelfoldername+"/"+whitePanelURL+"'>"
			parent.document.getElementById("whitehint_"+whitePanelfoldername).style.display=""
		}
	}
	
	
}

function unhint(whitePanelURL,whitePanelfoldername,darkerPanelURL,darkerPanelfoldername,GarmentType)
{
	
	
	parent.document.getElementById("blackhint_"+darkerPanelfoldername).style.display="none"
	parent.document.getElementById("whitehint_"+whitePanelfoldername).style.display="none"
}
function showcollars()
{
	//alert(1)
	//if(document.getElementById("collaritems"))
	//{
		ddaccordion.collapseall('expandable')
		document.getElementById("collaritems").style.display=""
		//document.getElementById("finalpanel").style.display="none"
	//}
	//$('#collaritems').show("slow")
	//$("#collaritems").show("slow")
}
function hidecollars()
{
	ddaccordion.collapseall('expandable')
	document.getElementById("collaritems").style.display="none"
	//document.getElementById("finalpanel").style.display=""
}
function viewquotes()
{
	document.location = 'custquotes.asp'
}
function viewsports()
{
	document.location = 'sports.asp'
}
function viewHierarchy()
{
	document.location = 'Hierarchy.asp'
}
function sendcustquote()
{
	var theemail
	theemail = document.getElementById("theemail").value
	getcustomerorder(theemail)
}
function getcustomerorder(theemail)
{
	var ordernum
	ordernum=document.getElementById("ordernum").value
	if(ordernum=="")
	{
		document.getElementById("quotedetails").innerHTML="Please enter an order number"
		document.getElementById("ordernum").focus
	}
	else
	{
		var url="Includes/customerquote.asp?ordernum="+ordernum+"&theemail="+theemail
  		xmlHttp=GetXmlHttpObject(QuotesAJAXCall);
   		xmlHttp.open("GET", url , true);
   		xmlHttp.send(null); 
	}
}
function QuotesAJAXCall()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
         var theresponse = xmlHttp.responseText
		 document.getElementById("quotedetails").innerHTML= theresponse

	}
}
function updatesport(sportid)
{
	if(document.getElementById("sportname_"+sportid).value=='')
	{
		alert('Please enter a Sport Name')
		document.getElementById("sportname_"+sportid).focus()
		return false;
	}
	var sportid = sportid
	var sportname = document.getElementById("sportname_"+sportid).value
	frames['hidden'].location.href = "/client/MKKSports/db/updatesport.asp?sportid="+ sportid+"&sportname="+sportname+"&action=none"
}
function enablesport(sportid)
{
	var answer = confirm("Are you sure you want to enable this sport?")
	if (answer)
	{
		frames['hidden'].location.href = "/client/MKKSports/db/updatesport.asp?sportid="+sportid+"&action=enable"
	}	
}
function disablesport(sportid)
{
	var answer = confirm("Are you sure you want to disable this sport?")
	if (answer)
	{
		frames['hidden'].location.href = "/client/MKKSports/db/updatesport.asp?sportid="+sportid+"&action=disable"
	}	
}
function newsport()
{
	if(document.getElementById("newsportname").value=='')
	{
		alert('Please enter a Sport Name')
		document.getElementById("newsportname").focus()
		return false;
	}
	var sportname=  document.getElementById("newsportname").value
	var active = document.getElementById("sportactive").value
	frames['hidden'].location.href = "/client/MKKSports/db/newsport.asp?sportname="+sportname+"&active="+active
}
function newtoplevel()
{
	if(document.getElementById("newtoplevelname").value=='')
	{
		alert('Please enter a Top Level Name')
		document.getElementById("newtoplevelname").focus()
		return false;
	}
	var newtoplevelname=  document.getElementById("newtoplevelname").value
	var active = document.getElementById("toplevelactive").value
	frames['hidden'].location.href = "/client/MKKSports/db/newtoplevel.asp?toplevelname="+newtoplevelname+"&active="+active
}
function reloadaccessoryimages(thevalue)
{
	if(thevalue!='')
	{
		document.location = 'UploadAccessoryImages.asp?thestyle='+thevalue	
	}
}
function reloadgarmentimages(thevalue)
{
	if(thevalue!='')
	{
		document.location = 'garments.asp?thesport='+thevalue	
	}
}
function startallover()
{
	var answer = confirm("Are you sure you want to start all over again, this will clear all your designs \nand allow you to start from scratch?")
	if (answer)
	{
		document.location="/client/MKKSports/main/includes/resetcookies.asp"
	}	
}
function revisitimage(garmenttype,garmentstyle,thesection)
{
	window.open ("http://www.wozaonline.com/client/MKKSports/main/screendump.asp?garmenttype="+garmenttype+"&garmentstyle="+garmentstyle+"&thesection="+thesection,"mywindow","location=1,status=0,toolbar=no, menubar=no, scrollbars=yes,addressbar=no,width=850,height=700");
}
function updatetopbottomlevel(theid)
{
	var thearraystring
	thearraystring=""
	
	for(i=0; i<eval("document.frm1"+theid).hierlist.length; i++)
	{
			if(eval("document.frm1"+theid).hierlist[i].checked==true)
			{
				thearraystring = thearraystring + eval("document.frm1"+theid).hierlist[i].value + ";"
			//alert(document.frm1.lookalikelist[i].value)
	}
		}
		if (thearraystring=='')
		{
			alert('Please select at least one item to go with this package!')
			return false
		}
frames['hidden'].location.href = "/client/MKKSports/db/updatelevel.asp?levelid="+theid+"&action=sublevels&thearraystring="+thearraystring
}

function showleveltosport(thevalue,thevalue2)
{
	
	
	var url="/client/MKKSports/Main/Includes/navbarchange.asp?theaction=showleveltosport&thevalue="+thevalue+"&thevalue2="+thevalue2
   //var inputone = prompt("Debug",url);
   xmlHttp=GetXmlHttpObject(showleveltosportCall);
   xmlHttp.open("GET", url , true);
   xmlHttp.send(null); 
}
function showleveltosportCall()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
        
		 var theresponse = xmlHttp.responseText
		 // alert(theresponse)
		 //document.getElementById("toplevel").style.display='none'
		 $("#leveltosport").show("fast")
		 $("#toplevel").hide("fast")
		 
		 document.getElementById("leveltosport").innerHTML=theresponse
		 //$("#leveltosport").hide("slow")
	}
}
function sporttogarment(thevalue,thevalue2)
{
	
	//alert(1)
	var url="/client/MKKSports/Main/Includes/navbarchange.asp?theaction=sporttogarment&thevalue="+thevalue+"&thevalue2="+thevalue2
   //var inputone = prompt("Debug",url);
   xmlHttp=GetXmlHttpObject(sporttogarmentCall);
   xmlHttp.open("GET", url , true);
   xmlHttp.send(null); 
}
function sporttogarmentCall()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
        
		 var theresponse = xmlHttp.responseText
		 // alert(theresponse)
		 if(document.getElementById("leveltosport"))
		 {
			 	//alert(document.getElementById("leveltosport").innerHTML)
				//document.getElementById("leveltosport").style.display="none"
		 }
		 //document.getElementById("leveltosport").style.display="none"
		 
		 //$("#leveltosport").hide("fast")
		 //$("#sporttogarment").show("slow")
		// document.getElementById("toplevel").style.display='none'
		 document.getElementById("leveltosport").innerHTML=theresponse
		 //$("#leveltosport").hide("slow")
	}
}
function backtosports()
{
	 document.getElementById("leveltosport").style.display="none"
	 document.getElementById("toplevel").style.display=""
}
function givehint(fieldid,fieldname,tablename,theid)
{
		//alert(1)
	var url="/client/MKKSports/Admin/includes/UploadComponentHint.asp?theid="+theid+"&tablename="+tablename+"&fieldname="+fieldname+"&fieldid="+fieldid
   //var inputone = prompt("Debug",url);
   xmlHttp=GetXmlHttpObject(gethint);
   xmlHttp.open("GET", url , true);
   xmlHttp.send(null); 
}
function gethint()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
        
		 var theresponse = xmlHttp.responseText
		 parent.document.getElementById("dropdownhint").innerHTML="You selected: "+theresponse+"<br>"
	
	}
}
function refreshdeletelistComponents(theid)
{
		document.location="DeleteImages.asp?Accessoryid="+theid
}
function refreshdeletelistGarments(theid)
{
		document.location="DeleteImages.asp?GarmentID="+theid
}