var focuscount=1;
function check_login()
{
	//alert('again in the function');
	if(document.getElementById("login_name").value=="")
	{
		
		document.getElementById("msg").innerHTML="<font color='red'>Please Provide correct Login Name</font>";
		return false;
	}
	if(document.getElementById("password").value=="")
	{
		
		document.getElementById("msg").innerHTML="<font color='red'>Please Provided correct Password </font>";
		return false;
	}
	
}
function car_model_validation(act)
{
	var fl;
	fl=act;
	if(document.getElementById("modelmake").value=="")
	{
		document.getElementById("msg").innerHTML="<font color='red'>Please Provide correct Car Make.</font>";
		return;
	}
	else if(document.getElementById("modelname").value=="")
	{
		document.getElementById("msg").innerHTML="<font color='red'>Please Provided correct Car Model. </font>";
		return;
	}
	else if(document.getElementById("version").value=="")
	{
		document.getElementById("msg").innerHTML="<font color='red'>Please Provide Version Name.</font>";
		return;
	}
	else if(document.getElementById("modellength").value=="")
	{
		document.getElementById("msg").innerHTML="<font color='red'>Please Provide correct Car Length.</font>";
		return;
	}
	else if(document.getElementById("modelwidth").value=="")	
	{
		document.getElementById("msg").innerHTML="<font color='red'>Please Provide correct Car Width.</font>";
		return;
	}
	else if(document.getElementById("modelheight").value=="")
	{	
		document.getElementById("msg").innerHTML="<font color='red'>Please Provide correct Car Height.</font>";
		return;
	}
	else if(checkFormat(document.getElementById("modelheight").value) && (checkFormat(document.getElementById("modelwidth").value)) && (checkFormat(document.getElementById("modellength").value)))
	{
		if(fl==1){
			document.getElementById('hdnvariable').value="submit_new_model";
		}else if(fl==2){
			document.getElementById('hdnvariable').value="update_new_model";			
		}	
		document.form.submit();
		
	}else {
	
		document.getElementById("msg").innerHTML="<font color='red'>Length, height and width must be in xxx.x format.</font>";
	}	
}

function AllowNumericOnly()
{
	if (window.event.keyCode < 48 || window.event.keyCode > 57)
		window.event.keyCode = 0;
}
function AllowDecimal()
{
	if (window.event.keyCode < 48 || window.event.keyCode > 57)
		if(window.event.keyCode != 46)
			window.event.keyCode = 0;
			
}
function checkFormat(size)
{
	
	var pos;
	var first;
	
	pos=size.indexOf('.');	
	if(pos > 3 || pos == 0)
	{		
		return false;
	}
	if(pos>0)
	{
		first = size.split('.')	;
		
		if(first[0].length>3)
			return false;
		if(first[1].length>1)
			return false;
	}
	return true;	
}	
function car_model_image_upload_validation()
{	
	
	if(document.getElementById("modelname").value=="0")
	{
		document.getElementById("msg").innerHTML="<font color='red'>Please select car model.</font>";
	}	
	else if(document.getElementById("modelcolor").value=="" )
	{
		document.getElementById("msg").innerHTML="<font color='red'>Please Provide correct Model Color Code</font>";
		return;
	}else if(document.getElementById("modelcolor").value.length!=6)
	{
		document.getElementById("msg").innerHTML="<font color='red'>Color Code should be 6 Character Long</font>";
		return;
	}else if((document.getElementById("modelleftview").value=="") || (document.getElementById("modelrightview").value=="") || (document.getElementById("modelfrontview").value=="") || (document.getElementById("modelbackview").value=="")){
		
		document.getElementById("msg").innerHTML="<font color='red'>Select the image for all views</font>";
	}
	else
	{
		document.getElementById('hdnvariable').value="submit_new_model_images";		
		document.form.submit();
	}
}
function car_model_image_update_validation()
{	
	document.getElementById('hdnvariable').value="update_new_model_images";
	document.form.submit();
}



function validatecategory()
{
	if(document.getElementById("category").value=="")
	{
		document.getElementById("msg").innerHTML = "<font color='red'>Please enter category name.</font>";		
	}else if(document.getElementById("category").value.length>30)
	{
		document.getElementById("msg").innerHTML = "<font color='red'>The Category Name Should less than 30 Characters.</font>";		
	}else
	{ 
		document.getElementById('hdnFormAction').value="addcategory";
		document.frmcategory.submit();	
	}	
}
function updatecategory()
{
	if(document.getElementById("category").value=="")
	{
		document.getElementById("msg").innerHTML = "<font color='red'>Please enter category name.</font>";		
	}else
	{
		document.getElementById('hdnFormAction').value="updatecategory";
		document.frmcategory.submit();	
	}
	
}
function saveclip(){
	if(document.frmclips.maincategory.value == 0)
	{
		document.getElementById("msg").innerHTML = "<font color='red'>Select the maincategory.</font>";
	}
	else if(document.frmclips.iname.value == "")
	{
		document.getElementById("msg").innerHTML = "<font color='red'>Enter the image name.</font>";
	}
	else if(document.frmclips.clips.value == "")
	{
		document.getElementById("msg").innerHTML = "<font color='red'>Please Upload a SWF file.</font>";		
		//return false;
	}
	else if(isNaN(document.frmclips.vroyality.value))
	{
		document.getElementById("msg").innerHTML = "<font color='red'>Enter only number in verndor royality.</font>";		
		//return false;
	}else 
	{
		document.frmclips.hdnFormAction.value="save";
		//return true;
		document.frmclips.submit();
	}	
}
function validate_registration()
{
	//alert('you are in the function');
	//alert(document.getElementById("confirmpassword").value);
	//alert(document.getElementById("chkTerms").checked);
	if(document.getElementById("first_name").value=="")	
	{
			//alert("in the if");
		document.getElementById("msg").innerHTML="<font color='red'>Please Provide your First Name</font>";		
		document.getElementById("first_name").focus();
		return false;
	}else if(document.getElementById("username").value=="")
	{
		document.getElementById("msg").innerHTML="<font color='red'>Please Provide Email Address</font>";		
		document.getElementById("username").focus();
		return false;		
	}
	else if(document.getElementById("userpassword").value=="")
	{
		document.getElementById("msg").innerHTML="<font color='red'>Please Provide your desired Password </font>";
		document.getElementById("userpassword").focus();
		return false;
	}
	else if(document.getElementById("userpassword").value.length<6)
	{
		document.getElementById("msg").innerHTML="<font color='red'>The password length should be atleast 6 characters</font>";
		document.getElementById("userpassword").focus();
		return false;
	}	
	else if(document.getElementById("confirmpassword").value != document.getElementById("userpassword").value)
	{	
		document.getElementById("msg").innerHTML="<font color='red'>Please specify the identical passwords</font>";
		document.getElementById("confirmpassword").focus();		
		return false;
		
	}
	else if(!(document.getElementById("chkTerms").checked))
	{
		
		document.getElementById("msg").innerHTML="<font color='red'>Please read and agree to our Terms and Conditions.</font>";
		document.getElementById("chkTerms").focus();
		return false;	
	}else if(document.getElementById("username").value!="")
	{
		var email_flag=true;
		var str=document.getElementById('username').value;
		var at='@'
		var dot='.'
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   document.getElementById("msg").innerHTML="<font color='red'>Invalid E-mail ID</font>";
		   document.getElementById("username").focus();
		    email_flag=false;
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   document.getElementById("msg").innerHTML="<font color='red'>Invalid E-mail ID</font>";
		   document.getElementById("username").focus();
		    email_flag=false;
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    document.getElementById("msg").innerHTML="<font color='red'>Invalid E-mail ID</font>";
		    document.getElementById("username").focus();
		     email_flag=false;
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    document.getElementById("msg").innerHTML="<font color='red'>Invalid E-mail ID</font>";
		    document.getElementById("username").focus();
		     email_flag=false;
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    document.getElementById("msg").innerHTML="<font color='red'>Invalid E-mail ID</font>";
		    document.getElementById("username").focus();
		     email_flag=false;
		    return false
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		    document.getElementById("msg").innerHTML="<font color='red'>Invalid E-mail ID</font>";
		    document.getElementById("username").focus();
		     email_flag=false;
		    return false
		 }
		
		 if (str.indexOf(' ')!=-1){
		    document.getElementById("msg").innerHTML="<font color='red'>Invalid E-mail ID</font>";
		    document.getElementById("username").focus();
		    email_flag=false;
		    return false
		 }
		 if (email_flag==true)
		 {
		 	document.form.submit();
		 }
	}
	else
	{
		
		document.form.submit();
	}	
	
}
function check_registration()
{
	
	if(document.getElementById("username").value=="")
	{
		document.getElementById("msg").innerHTML="<font color='red'>Please Provide correct UserName</font>";
		document.getElementById("username").focus();
		return false;
	}
	else if(document.getElementById("userpassword").value=="")
	{
		document.getElementById("msg").innerHTML="<font color='red'>Please Provided correct Password </font>";
		document.getElementById("userpassword").focus();
		return false;
	}
	else if(document.getElementById("userpassword").value!="")
	{
		if(document.getElementById("userpassword").value.length<6)
		{
			document.getElementById("msg").innerHTML="<font color='red'>Please Provided correct Password </font>";
			document.getElementById("userpassword").focus();
			return false;
		}
			
	}
	else if(document.getElementById("confirmpassword").value=="")
	{	
		document.getElementById("msg").innerHTML="<font color='red'>Please Provide correct Confirmation Password</font>";
		document.getElementById("confirmpassword").focus();
		return false;
	}
	else if(document.getElementById("confirmpassword").value!="")
	{
		if(document.getElementById("confirmpassword").value!=document.getElementById("userpassword").value)
		{	
			document.getElementById("msg").innerHTML="<font color='red'>Please Provide correct Password</font>";
			document.getElementById("confirmpassword").focus();
			return false;
		}	
	}
	if(document.getElementById("first_name").value=="")	
	{
		document.getElementById("msg").innerHTML="<font color='red'>Please Provide correct First Name</font>";
		document.getElementById("first_name").focus();
		return false;
	}
	else if(document.getElementById("address1").value=="")
	{
		document.getElementById("msg").innerHTML="<font color='red'>Please Provide correct Address</font>";
		document.getElementById("address1").focus();
		return false;
	}
	else if(document.getElementById("city").value=="")
	{
		document.getElementById("msg").innerHTML="<font color='red'>Please Provide correct City</font>";
		document.getElementById("city").focus();
		return false;
	}
	else if(document.getElementById("state").value=="")
	{
		document.getElementById("msg").innerHTML="<font color='red'>Please Provide correct State</font>";
		document.getElementById("state").focus();
		return false;
	}
	else if(document.getElementById("country").value=="")
	{
		document.getElementById("msg").innerHTML="<font color='red'>Please Provide correct Country</font>";
		document.getElementById("country").focus();
		return false;
	}
	else if(document.getElementById("phone").value=="")
	{
		document.getElementById("msg").innerHTML="<font color='red'>Please Provide correct Phone Number</font>";
		document.getElementById("phone").focus();
		return false;
	}
	else if(document.getElementById("email").value=="")
	{
		document.getElementById("msg").innerHTML="<font color='red'>Please Provide correct Email Address</font>";
		document.getElementById("email").focus();
		return false;
	}
	else if(document.getElementById("email").value!="")
	{
		var email_flag=true;
		var str=document.getElementById('email').value;
		var at='@'
		var dot='.'
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   document.getElementById("msg").innerHTML="<font color='red'>Invalid E-mail ID</font>";
		   document.getElementById("email").focus();
		    email_flag=false;
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   document.getElementById("msg").innerHTML="<font color='red'>Invalid E-mail ID</font>";
		   document.getElementById("email").focus();
		    email_flag=false;
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    document.getElementById("msg").innerHTML="<font color='red'>Invalid E-mail ID</font>";
		    document.getElementById("email").focus();
		     email_flag=false;
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    document.getElementById("msg").innerHTML="<font color='red'>Invalid E-mail ID</font>";
		    document.getElementById("email").focus();
		     email_flag=false;
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    document.getElementById("msg").innerHTML="<font color='red'>Invalid E-mail ID</font>";
		    document.getElementById("email").focus();
		     email_flag=false;
		    return false
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		    document.getElementById("msg").innerHTML="<font color='red'>Invalid E-mail ID</font>";
		    document.getElementById("email").focus();
		     email_flag=false;
		    return false
		 }
		
		 if (str.indexOf(' ')!=-1){
		    document.getElementById("msg").innerHTML="<font color='red'>Invalid E-mail ID</font>";
		    document.getElementById("email").focus();
		    email_flag=false;
		    return false
		 }
		 if (email_flag==true)
		 {
		 	document.form.submit();
		 }
	}
	else
	{
		
		document.form.submit();
	}	
}

<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function upload_image_check()
{
	if(document.getElementById("imagename").value=="")
	{
		document.getElementById("msg").innerHTML="<font color='red'>Please provide the Image Name</font>";
		return false;
	}
	else
	{
		if(document.getElementById("height").value=="")
		{
			document.getElementById("msg").innerHTML="<font color='red'>Please provide the length of Image </font>";
			return false;
		}
		else
		{
			if(document.getElementById("width").value=="")
			{
			document.getElementById("msg").innerHTML="<font color='red'>Please provide the breadth of Image </font>";
			return false;
			}
			
		}
	}
}
function forgetpass()
{
			
				
				if(document.getElementById("username").value=="")
				{
					document.getElementById("msg").innerHTML="<font color='red'>Please specify the Email</font>";
					return false;
				}
		
		
			
			
		
}

function changepass()
{
	
		if(document.getElementById("cpass").value=="" || document.getElementById("rpass").value=="" || document.getElementById("npass").value=="")
			{
				document.getElementById("msg").innerHTML="<font color='red'>Please fill all the boxes</font>";
				return false;
			}
			else
				if(document.getElementById("npass").value!=document.getElementById("rpass").value)
				{
					document.getElementById("msg").innerHTML="<font color='red'>Please Specify the Same new Passowrds</font>";
					return false;
				}
				else
					if(document.getElementById("npass").value.length<6)
					{
						document.getElementById("msg").innerHTML="<font color='red'>Password length should be atleast 6 characters.</font>";
						return false;
					}
	subform();					
}
/* The following function creates an XMLHttpRequest object... */

function createRequestObject(){
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}

/* You can get more specific with version information by using 
	parseInt(navigator.appVersion)
	Which will extract an integer value containing the version 
	of the browser being used.
*/
/* The variable http will hold our new XMLHttpRequest object. */
var http = createRequestObject(); 

function callajax1()
{
			http.open('get', 'callajax.php?action=reg&sstr=' 
					+ document.getElementById('username').value);
			/* Define a function to call once a response has been received. This will be our
				handleProductCategories function that we define below. */
			http.onreadystatechange = handleRegistration; 
			/* Send the data. We use something other than null when we are sending using the POST
				method. */
			http.send(null);	
	
	
}

function handleRegistration(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
		
		document.getElementById( 'diverrorreg' ).style.visibility = "visible";
		
		//alert(document.frmclips.keyword.offsetLeft);
		
		document.getElementById('diverrorreg').innerHTML = response;
	}
}
function checkdivlogin()
{
	
	if(document.getElementById('divusername').value=='' && document.getElementById('divpass').value=='')
	{
		document.getElementById('diverror').style.visibility="visible";
		document.getElementById('diverror').innerHTML='Please fill all the boxes';
	}
	else
	{
		callajax();
	}
	
}

function callajax()
{
			http.open('get', 'callajax.php?action=check&sstr=' 
					+ document.getElementById('divusername').value+'|'+document.getElementById('divpass').value);
			/* Define a function to call once a response has been received. This will be our
				handleProductCategories function that we define below. */
			http.onreadystatechange = handleLogin; 
			/* Send the data. We use something other than null when we are sending using the POST
				method. */
			http.send(null);	
	
	
}

function handleLogin(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
		
		document.getElementById( 'diverror' ).style.visibility = "visible";
		
		//alert(document.frmclips.keyword.offsetLeft);
		
		document.getElementById('diverror').innerHTML = response;
	}
}


function checklogin(str){
	/* Create the request. The first argument to the open function is the method (POST/GET),
		and the second argument is the url... 
		document contains references to all items on the page
		We can reference document.form_category_select.select_category_select and we will 		
		be referencing the dropdown list. The selectedIndex property will give us the 
		index of the selected item. 
	*/
	
	if(str=='login')
	{
			document.getElementById('loginpage').style.visibility="visible";
			document.getElementById('regpage').style.visibility="hidden";
	}
	else
	{
			document.getElementById('loginpage').style.visibility="hidden";
			document.getElementById('regpage').style.visibility="visible";
	}
	//http.open('get', 'ajaxchek.php?action=get_key&sstr=' 
			///+ document.getElementById('keyword').value);
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	//http.onreadystatechange = handleCategory; 
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	//http.send(null);
}
/* Function called to get the product categories list */
function getkeywords(){
	/* Create the request. The first argument to the open function is the method (POST/GET),
		and the second argument is the url... 
		document contains references to all items on the page
		We can reference document.form_category_select.select_category_select and we will 		
		be referencing the dropdown list. The selectedIndex property will give us the 
		index of the selected item. 
	*/
	
	http.open('get', 'ajaxback.php?action=get_key&sstr=' 
			+ document.getElementById('keyword').value);
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	http.onreadystatechange = handleCategory; 
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send(null);
}

function getkeywords1(e){
	/* Create the request. The first argument to the open function is the method (POST/GET),
		and the second argument is the url... 
		document contains references to all items on the page
		We can reference document.form_category_select.select_category_select and we will 		
		be referencing the dropdown list. The selectedIndex property will give us the 
		index of the selected item. 
	
	*/
http.open('get', 'ajaxback.php?action=get_key1&sstr=' 
			+ document.getElementById('keyword').value);
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	alert(focuscount);
	http.onreadystatechange = handleCategory1; 
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send(null);
var key;
				if (window.event)
				{
					key = window.event.keyCode;     //IE
				}
				else
				{
					key = e.which;     //firefox
				}		
		
	
	if(key==13)
		{
			str='azra'+focuscount;
			document.getElementById('keyword').value=document.getElementById('keyword').value+', '+document.getElementById(str).value;

		}
	if(focuscount<10)
	{
		if(key==40)
		{
			
			str='azra'+(focuscount+1);
			document.getElementById(str).focus();
			focuscount=focuscount+1;
		}
	}
	if(focuscount>1)
	{
		if(key==38)
		{
			str='azra'+(focuscount-1);
			document.getElementById(str).focus();
			focuscount=focuscount-1;
		}
	}
	
	
	
	
}

/* Function called to handle the list that was returned from the internal_request.php file.. */
function handleCategory(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
		
		document.getElementById( 'key' ).style.visibility = "visible";
		
		//alert(document.frmclips.keyword.offsetLeft);
		
		document.getElementById('key').innerHTML = response;
	}
}
function handleCategory1(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
		
		document.getElementById( 'key' ).style.visibility = "visible";
		
		//alert(document.frmclips.keyword.offsetLeft);
		
		document.getElementById('key').innerHTML = response;
	}
}
function selectkeyword(str)
{
				
				var no=document.getElementById("keymenu");
				var txt=document.getElementById("keyword").value;
				txt=txt.substr(0,(txt.length)-1);
				txt= txt+str+',';
				document.getElementById("keyword").value=txt;
				document.getElementById("keyword").focus();
				document.getElementById( 'key' ).style.visibility = "hidden";
				
		
}
function MM_openBrWindow(theURL,winName,features) { //v2.0

 window.open(theURL,winName,features);
}

function MM_openDesignStudio(theURL) { //v2.0

 window.open("www.google.com",'Design Studio',"width=958,height=674,resizable=1,scrollbars=yes");
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////   These functions are user in subcategorylist.php to call Ajax Function 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////  
function getsubcats(){
	/* Create the request. The first argument to the open function is the method (POST/GET),
		and the second argument is the url... 
		document contains references to all items on the page
		We can reference document.form_category_select.select_category_select and we will 		
		be referencing the dropdown list. The selectedIndex property will give us the 
		index of the selected item. 
	*/
	
	http.open('get', 'ajaxback.php?action=get_subcattable&sstr=' 
			+ document.getElementById('maincategory').value);
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	http.onreadystatechange = handleSubcat; 
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send(null);
}

/* Function called to handle the list that was returned from the internal_request.php file.. */
function handleSubcat(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
		
		document.getElementById( 'showsubcat' ).style.visibility = "visible";
		
		//alert(document.frmclips.keyword.offsetLeft);
		
		document.getElementById('showsubcat').innerHTML = response;
		//alert(response);
	}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 				Function to Check Avialblity for Image Name
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
function checkimgname(){
	/* Create the request. The first argument to the open function is the method (POST/GET),
		and the second argument is the url... 
		document contains references to all items on the page
		We can reference document.form_category_select.select_category_select and we will 		
		be referencing the dropdown list. The selectedIndex property will give us the 
		index of the selected item. 
	*/
	//alert(document.getElementById('imagename').value);
	//alert(document.getElementById('imagename').value);
	http.open('get', 'ajaxback.php?action=namesearch&str=' 
			+ document.getElementById('imagename').value);
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	http.onreadystatechange = handleimagename; 
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send(null);
}

/* Function called to handle the list that was returned from the internal_request.php file.. */
function handleimagename(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
		
		document.getElementById( 'error' ).style.visibility = "visible";
		
		//alert(document.frmclips.keyword.offsetLeft);
		//alert(response);
		document.getElementById('error').innerHTML = response;
		
	}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
function getsubcats1(str){
	/* Create the request. The first argument to the open function is the method (POST/GET),
		and the second argument is the url... 
		document contains references to all items on the page
		We can reference document.form_category_select.select_category_select and we will 		
		be referencing the dropdown list. The selectedIndex property will give us the 
		index of the selected item. 
	*/
	str1='maincategory'+str;
	//alert(str1);
	http.open('get', 'ajaxback.php?action=get_subcat&sstr=' 
			+ document.getElementById(str1).value+'&name='+str);
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	if(str==1)
		http.onreadystatechange = handleSubcat1; 
	if(str==2)
		http.onreadystatechange = handleSubcat2; 
	if(str==3)
		http.onreadystatechange = handleSubcat3; 
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send(null);
}

/* Function called to handle the list that was returned from the internal_request.php file.. */
function handleSubcat1(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
		
		document.getElementById( 'showsubcat1' ).style.visibility = "visible";
		
		//alert(document.frmclips.keyword.offsetLeft);
		//alert(response);
		document.getElementById('showsubcat1').innerHTML = response;
		//alert(response);
	}
}
function handleSubcat2(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
		
		document.getElementById( 'showsubcat2' ).style.visibility = "visible";
		
		//alert(document.frmclips.keyword.offsetLeft);
		//alert(response);
		document.getElementById('showsubcat2').innerHTML = response;
		//alert(response);
	}
}
function handleSubcat3(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
		
		document.getElementById( 'showsubcat3' ).style.visibility = "visible";
		
		//alert(document.frmclips.keyword.offsetLeft);
		//alert(response);
		document.getElementById('showsubcat3').innerHTML = response;
		//alert(response);
	}
}


function validatesubcat()
{
//alert(document.getElementById("subcategory").value);
if(document.getElementById("subcategory").value=="")
	{
		document.getElementById("msg").innerHTML = "<font color='red'>Please enter Sub Category name.</font>";
		return false;
	}else if(document.getElementById("subcategory").value.length>30)
	{
		document.getElementById("msg").innerHTML = "<font color='red'>The Sub Category Name Should less than 30 Characters.</font>";
		return false;
	}		
	
	
}
/////////////////////////////////////////////////////////////////////
//  Function for checking the unique ness of the Artist Name
/////////////////////////////////////////////////////////////////////
function checkartistname(){
	/* Create the request. The first argument to the open function is the method (POST/GET),
		and the second argument is the url... 
		document contains references to all items on the page
		We can reference document.form_category_select.select_category_select and we will 		
		be referencing the dropdown list. The selectedIndex property will give us the 
		index of the selected item. 
	*/
	//alert(str1);
	document.getElementById('showstatus').style.visiblity='hidden';
	http.open('get', 'ajaxback.php?action=get_artist&sstr=' 
			+ document.getElementById('sname').value);
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	
		http.onreadystatechange = checkartist; 
	
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send(null);
}

/* Function called to handle the list that was returned from the internal_request.php file.. */
function checkartist(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
		
		document.getElementById( 'showstatus' ).style.visibility = "visible";
		
		//alert(document.frmclips.keyword.offsetLeft);
		//alert(response);
		document.getElementById('showstatus').innerHTML = response;
		//alert(response);
	}
}
//////////////////////////////////////////////////////////////////////////
// Function to check the to Enter Numeric value
/////////////////////////////////////////////////////////////////////////
function AllowNumericOnly1l(str,str1)
{
		
		//alert('you are in the function');
		var arr= new Array();
		arr=str.split('|');
		var x='';
		for(j=0;j<str1;j++)
		{
			
				x= document.getElementById(arr[i]).value;
				flag=0;;
				for(i=0;i<x.length;i++)
				{
						if(x.charAt(i)< "0" || x.charAt(i) > "9")
						{
								flag=1;
								break;
						}
				
				}
				if(flag==1)
				{
					document.getElementById('errmsg').innerHTML='<font color="red">Please fill Numeric values for Zip and Phone</font>';
					return false;
				}
				
		}
		return true;
			
		
}
/////////////////////////////////////////////////////////////////////////
//................................................................................
//        Code for validation of Upload image form UI
//.................................................................................
function validateuploadform()
{
	
	if(document.getElementById('imagename').value=='')
		{
			document.getElementById('errmsg').innerHTML='<font color="red">Please Provide the image name</font>';
					return false;
		}
		if(document.getElementById('maincategory1').value==0 && document.getElementById('maincategory2').value==0 && document.getElementById('maincategory3').value==0)
		{
			document.getElementById('errmsg').innerHTML='<font color="red">Please select atleast one main category</font>';
					return false;
		}
		if(document.getElementById('imageadd').value=='')
		{
			document.getElementById('errmsg').innerHTML='<font color="red">Please Provide the image path</font>';
					return false;
		}
		
		
		var img=document.getElementById('imageadd').value;
	
		var imgval=img.split('.');
		if((imgval[1]=="eps") || (imgval[1]=="EPS"))
		{
			if(false)
			{
			document.getElementById('errmsg').innerHTML='<font color="red">Image Type not Supported.</font>';
					return false;
			}
		}
		
		if(!(document.getElementById("check").checked))
		{
		alert("Please click the checkbox to agree to license your image to CarArt according to our Terms of Service");
		document.getElementById("check").focus();
		document.getElementById("check").style.background="#990000";
		document.getElementById('errmsg').innerHTML='<font color="red">Please read and agree to our Terms of Service.</font>';

					return false;	
		}
		
		if(document.getElementById('ramt1').value!='')
		{
		if(parseFloat(document.getElementById('ramt1').value))
		{
		flag=0;
		}
		else {
		flag=1;	
		}
			
		if(flag==1)
			{
				document.getElementById('errmsg').innerHTML='<font color="red">Please fill Numeric or Float value Royalty amount</font>';
				return false;
			}
	}
	
	
		
	
}
//.................................................................................
/////////////////////////////////////////////////////////////////
//		Function to call the ajax for the Front page of the site
/////////////////////////////////////////////////////////////////
	function checkcarmake(str){
	/* Create the request. The first argument to the open function is the method (POST/GET),
		and the second argument is the url... 
		document contains references to all items on the page
		We can reference document.form_category_select.select_category_select and we will 		
		be referencing the dropdown list. The selectedIndex property will give us the 
		index of the selected item. 
	*/
	
	
	http.open('get', 'ajaxback.php?action=check_carmake&sstr=' 
			+ str);
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	
		http.onreadystatechange = checkmakecar; 
	
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send(null);
}

/* Function called to handle the list that was returned from the internal_request.php file.. */
function checkmakecar(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
		
		
		
		//alert(document.frmclips.keyword.offsetLeft);
		//alert(response);
		document.getElementById('carmake').innerHTML = response;
		//alert(response);
	}
}
////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
//		Function to call the ajax for the Front page of the site
/////////////////////////////////////////////////////////////////
	function checkcarmodel(str){
	/* Create the request. The first argument to the open function is the method (POST/GET),
		and the second argument is the url... 
		document contains references to all items on the page
		We can reference document.form_category_select.select_category_select and we will 		
		be referencing the dropdown list. The selectedIndex property will give us the 
		index of the selected item. 
	*/
	
	

	http.open('get', 'ajaxback.php?action=check_carmodel&sstr=' 
			+ str);
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	
		http.onreadystatechange = checkmodelcar; 
	
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send(null);
}

/* Function called to handle the list that was returned from the internal_request.php file.. */
function checkmodelcar(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
		
		
		
		//alert(document.frmclips.keyword.offsetLeft);
		
		document.getElementById('carmodel').innerHTML = response;
	
	}
}
////////////////////////////////////////////////////////////////



/////////////////////////////////////////////////////////////////
//		Function to call the ajax for the Front page of the site
/////////////////////////////////////////////////////////////////
	
function checkcarversion(str,str1,str2){
	/* Create the request. The first argument to the open function is the method (POST/GET),
		and the second argument is the url... 
		document contains references to all items on the page
		We can reference document.form_category_select.select_category_select and we will 		
		be referencing the dropdown list. The selectedIndex property will give us the 
		index of the selected item. 
	*/
	
	
	http.open('get', 'ajaxback.php?action=check_carversion&sstr=' 
			+ str+'&ssstr='+str1+'&str='+str2);
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	
		http.onreadystatechange = checkversioncar; 
	
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send(null);
}

/* Function called to handle the list that was returned from the internal_request.php file.. */
function checkversioncar(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
		
		
		
		//alert(document.frmclips.keyword.offsetLeft);
	
		document.getElementById('carversion').innerHTML = response;
	
	}
}


//populate NEW dropdown with year and version
function checkcarversionyear(str,str1){
	/* Create the request. The first argument to the open function is the method (POST/GET),
		and the second argument is the url... 
		document contains references to all items on the page
		We can reference document.form_category_select.select_category_select and we will 		
		be referencing the dropdown list. The selectedIndex property will give us the 
		index of the selected item. 
	*/
	
	
	http.open('get', 'ajaxback.php?action=check_carversion&sstr=' 
			+ str+'&ssstr='+str1);
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	
		http.onreadystatechange = checkversioncaryear; 
	
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send(null);
}

/* Function called to handle the list that was returned from the internal_request.php file.. */
function checkversioncaryear(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
		
		
		
		//alert(document.frmclips.keyword.offsetLeft);
	
		document.getElementById('version_year').innerHTML = response;
	
	}
}


//populate NEW dropdown with year and version
function makedesignstudio(str){
	/* Create the request. The first argument to the open function is the method (POST/GET),
		and the second argument is the url... 
		document contains references to all items on the page
		We can reference document.form_category_select.select_category_select and we will 		
		be referencing the dropdown list. The selectedIndex property will give us the 
		index of the selected item. 
	*/
	http.open('get', 'ajaxback.php?action=make_design_studio&sstr=' 
			+ str);
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	
		http.onreadystatechange = makestudiolaunch; 
	
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send(null);
}

/* Function called to handle the list that was returned from the internal_request.php file.. */
function makestudiolaunch(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
		
		
		
		//alert(document.frmclips.keyword.offsetLeft);
	//alert(response);
		document.getElementById('design_studio').innerHTML = response;
	
	}
}


function check ()
{
	
	if(document.getElementById('chkemail').value="on")
	{
	alert("You cannot deny to except Marketing Emails.");
	document.getElementById('chkemail').checked="checked";
	}
	
	
}

////////////////////////////////////////////////////////////////
//////
