var videoWin = null;
function videoWindow(mypage,myname,w,h) 
{
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no,resizable=no';
	videoWin = window.open(mypage,myname,settings);
}

// Pop-Up Window
var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
if(win.window.focus){win.window.focus();}}
function CloseNewWin(){if(win!=null && win.open)win.close()}
window.onfocus=CloseNewWin;

function itemSearch(item)
{
	if(item == 'awards') sendTo('VIEW AWARDS', 'GENERAL', 'awards', 'media', '');
	else if(item == 'logos') sendTo('VIEW LOGOS', 'GENERAL', 'logos', 'media', '');
	else if(item == 'parts') sendTo('VIEW PARTS', 'GENERAL', 'parts', 'media', '');
	else if(item == 'photos') sendTo('VIEW PHOTOS', 'GENERAL', 'photos', 'media', '');
	else if(item == 'alive!') sendTo('VIEW PRODUCTLINE', 'KNEX SETS', 'Alive!', 'media', '');
	else if(item == 'familyfun') sendTo('VIEW PRODUCTLINE', 'KNEX SETS', 'FamilyFun', 'media', '');
	else if(item == 'rekonstructors') sendTo('VIEW PRODUCTLINE', 'KNEX SETS', 'ReKonstructors', 'media', '');
	else if(item == 'tubsandcases') sendTo('VIEW PRODUCTLINE', 'KNEX SETS', 'Tubs and Cases', 'media', '');
	else if(item == 'xbattlers') sendTo('VIEW PRODUCTLINE', 'KNEX SETS', 'XBattlers', 'media', '');
	else if(item == 'xwheels') sendTo('VIEW PRODUCTLINE', 'KNEX SETS', 'XWheels', 'media', '');
	else if(item == 'kidknex') sendTo('VIEW PRODUCTLINE', 'KID KNEX', 'KidKNEX', 'media', '');
	else if(item == 'lidkids') sendTo('VIEW PRODUCTLINE', 'KID KNEX', 'lidkids', 'media', '');
	else if(item == 'lincolnlogs') sendTo('VIEW PRODUCTLINE', 'SISTER PRODUCTS', 'Lincoln Logs', 'media', '');
	else if(item == 'laserstrike') sendTo('VIEW PRODUCTLINE', 'SISTER PRODUCTS', 'Laser Strike', 'media', '');
	else if(item == 'promotional') sendTo('VIEW SALES DATA TYPE', '', '13', 'media', '');
}

function advancedSearch(keyword)
{
	if(keyword.length != 0)
		sendTo('ADV SEARCH', '', '', 'media', keyword);
}

function salesAccessRequestFormValidate()
{
	if(document.salesAccessRequestForm.company.value.length < 1)
	{
		alert("Please Enter Your Company Name.");
		return;
	}
	else if(document.salesAccessRequestForm.firstname.value.length < 1)
	{
		alert("Please Enter Your First Name.");
		return;
	}
	else if(document.salesAccessRequestForm.lastname.value.length < 1)
	{
		alert("Please Enter Your Last Name.");
		return;
	}
	else if(invalidEmail(document.salesAccessRequestForm.email.value))
	{
		alert("Please Enter a valid Email Address.");
		return;
	}		
	else if(document.salesAccessRequestForm.address1.value.length < 1)
	{	
		alert("Please Enter your Address.");
		return;
	}						
	else if(document.salesAccessRequestForm.city.value.length < 1)
	{	
		alert("Please select your city.");
		return;
	}			
	else if(document.salesAccessRequestForm.state.value == 0)
	{
		alert("Please select your state.");
		return;
	}
	else if(document.salesAccessRequestForm.zip.value.length < 5)
	{
		alert("Please Enter Your Zip Code.");
		return;	
	}
	else if(document.salesAccessRequestForm.phone.value.length < 7)
	{
		alert("Please Enter Your Phone Number.");
		return;
	}
	else if(document.salesAccessRequestForm.username.value.length < 5)
	{
		alert("Please Enter a username that is atleast 5 characters.");
		return;
	}
				
	document.salesAccessRequestForm.submit();
}
//End

//Validate Email function used in ADMIN_CUSTOMER_INFO.PHP AND ADMIN_CUSTOMER_ADDITION.PHP
			function invalidEmail( email ) 
			{
				if( email == "" ) 
				{
					return true;
				}

				atPos = email.indexOf("@");

				if( atPos == -1 ) 
				{
					return true;
				}

				if( email.indexOf(".", atPos) == -1 ) 
				{
					return true;
				}    

				return false;  
			}
//Validate Email function	

function alphaImage(strPath, intWidth, intHeight) 
{ 
            var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;
			if (isIE)
			{
			   document.write('<div style="height:'+intHeight+'px;width:'+intWidth+'px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+strPath+'.png\', sizingMethod=\'scale\')" /></div>');
			}
			else
			{
	           document.write('<img src="'+strPath+'.png" border="0" height='+intHeight+' width='+intWidth+' />');
			}
}

function validateFtpData(type)
{				
				if(document.form1.name.value.length < 1)
				{
					alert("Please Enter a Name for the File that Sales users will see on the K'NEXtranet.");
					return;
				}
				else if(document.form1.typeid.value == 0)
				{
					alert("Please Select a Sales Data Type.");
					return;
				}
				else if(document.form1.author.value.length < 1)
				{
					alert("Please Enter the Name of the Author.");
					return;
				}
				else if(document.form1.descr.value.length < 1)
				{
					alert("Please Enter a Short Description for the File.");
					return;
				}
				
				if(type == "modify")  //this will be true if we are coming from the ADMIN_SALESDATA_INFO form.
				{
					if(document.form1.uploadedFile.value.length > 1)
					{
						msg = "Are you sure you want to replace the file with the new one selected?";
						if(!confirm(msg)) return;
						
						//They want to replace the old file with the new one selected.
						document.form1.replaceFile.value = "yes";
					}
				}	
				else  //Form from the ADMIN_SALESDATA_ADDITION where a file must be selected.
				{
					if(document.form1.uploadedFile.value.length < 1)
					{
						alert("Please Select a File to Upload.");
						return;
					}				
				}
				
				document.form1.submit();
}

//Validate FTP File Privileges
function validateFtpFilePrivileges()
{
				var optionCounter;
				var theElement = document.form1.accessArray;
				document.form1.accessArrayString.value = "";
		
				for(optionCounter=0; optionCounter < theElement.length; optionCounter++) 
				{
					if(document.form1.accessArray[optionCounter].checked == true)
					{
						document.form1.accessArrayString.value =  document.form1.accessArray[optionCounter].value + ":::" + document.form1.accessArrayString.value;
					}			
				}			
				document.form1.accessArrayString.value = " Begin:::" + document.form1.accessArrayString.value;
				//alert(document.form1.accessArrayString.value);
				document.form1.submit();
}


//Validate FTP File Privileges
function FtpFilePrivilegesAdded()
{
				var optionCounter;
				var theElement = document.form1.accessArray;
				document.form1.accessArrayString.value = "";
		
				for(optionCounter=0; optionCounter < theElement.length; optionCounter++) 
				{
					if(document.form1.accessArray[optionCounter].checked == true)
					{
						document.form1.accessArrayString.value =  document.form1.accessArray[optionCounter].value + ":::" + document.form1.accessArrayString.value;
					}			
				}			
				document.form1.accessArrayString.value = " Begin:::" + document.form1.accessArrayString.value;
				//alert(document.form1.accessArrayString.value);
				document.form1.submit();
}


