function search(){
	var categorySelected = document.getElementById('categoryId').selectedIndex;
	var category = document.getElementById('categoryId').options[categorySelected].value;
	if(category == '0')category='';
	var searchText=document.getElementById("searchTextBox").value;
	location.href='/search/PRODUCT/'+category+'/'+searchText;	
}

function submitAddToCart(productId,retailerId,sessionId){
	window.location="/shoppingCart?productId="+productId+"&retailerId="+retailerId+"&sessionId="+sessionId;
}

function sortSearch(categoryId,searchText,sortColumn,pageNumber){
	if(sortColumn.value != ''){
		var currUrl = window.location+'';
		var firstIndx = currUrl.indexOf('attributes');
		var url = '/search?type=PRODUCT&categoryId='+categoryId+'&text='+searchText+'&sortColumn='+sortColumn.value;
		if(firstIndx > 50){
			var length =  currUrl.length;	
			var attributes = currUrl.substring(firstIndx,length);
			url = url+'&'+attributes;
		}
		if(pageNumber != ''){
			if(url.indexOf('&page=') == -1){	
				url = url+'&page='+pageNumber	
			}		
		}	
		location.href=url;
	}	
}
function productDownload(){
var catId=document.getElementById("category").value;
var brandName=document.getElementById("brandId").value;
if(catId=="" || catId== null){
alert("Please select category for download products");
return false;
}
window.location="/adminprodscats?downloadProducts&categoryId="+catId+"&brandName="+brandName;
}
function productSampleDownload(){
var catId=document.getElementById("category").value;
if(catId=="" || catId== null){
alert("Please select category for download products");
return false;
}
window.location="/adminprodscats?downloadSampleExcel&categoryId="+catId;
}
function displayHelp(text){
	document.getElementById(text).style.display = 'block';
}
function hideHelp(text){
	document.getElementById(text).style.display = 'none';
}

function setDefaultSelection(selectedValue){
	var selectedIndex = 0;
	if(selectedValue == 'Product_Name'){
		selectedIndex = 1;
	}
	if(selectedValue == 'Product_Rating'){
		selectedIndex = 2;
	}
	if(selectedValue == 'Product_Price'){
		selectedIndex = 3;
	}
	if(selectedValue == 'Retailer_Price'){
		selectedIndex = 4;
	}
	document.getElementById('sortColumnId').options[selectedIndex].selected = true;
}


function initTinyMCE(){
	var RTE_elements = '';
	var _fieldName;
	var _url;
	var _type;
	var _win;
	tinyMCE.init({
		mode : "exact",
		theme : "advanced",
		entities : "160,nbsp,38,amp,34,quot,162,cent,8364,euro,163,pound,165,yen,169,copy,174,reg,8482,trade,8240,permil,181,micro,183,middot,8226,bull,8230,hellip,8242,prime,8243,Prime,167,sect,182,para,223,szlig,8249,lsaquo,8250,rsaquo,171,laquo,187,raquo,8216,lsquo,8217,rsquo,8220,ldquo,8221,rdquo,8218,sbquo,8222,bdquo,60,lt,62,gt,8804,le,8805,ge,8211,ndash,8212,mdash,175,macr,8254,oline,164,curren,166,brvbar,168,uml,161,iexcl,191,iquest,710,circ,732,tilde,176,deg,8722,minus,177,plusmn,247,divide,8260,frasl,215,times,185,sup1,178,sup2,179,sup3,188,frac14,189,frac12,190,frac34,402,fnof,8747,int,8721,sum,8734,infin,8730,radic,8764,sim,8773,cong,8776,asymp,8800,ne,8801,equiv,8712,isin,8713,notin,8715,ni,8719,prod,8743,and,8744,or,172,not,8745,cap,8746,cup,8706,part,8704,forall,8707,exist,8709,empty,8711,nabla,8727,lowast,8733,prop,8736,ang,180,acute,184,cedil,170,ordf,186,ordm,8224,dagger,8225,Dagger,192,Agrave,194,Acirc,195,Atilde,196,Auml,197,Aring,198,AElig,199,Ccedil,200,Egrave,202,Ecirc,203,Euml,204,Igrave,206,Icirc,207,Iuml,208,ETH,209,Ntilde,210,Ograve,212,Ocirc,213,Otilde,214,Ouml,216,Oslash,338,OElig,217,Ugrave,219,Ucirc,220,Uuml,376,Yuml,222,THORN,224,agrave,226,acirc,227,atilde,228,auml,229,aring,230,aelig,231,ccedil,232,egrave,234,ecirc,235,euml,236,igrave,238,icirc,239,iuml,240,eth,241,ntilde,242,ograve,244,ocirc,245,otilde,246,ouml,248,oslash,339,oelig,249,ugrave,251,ucirc,252,uuml,254,thorn,255,yuml,914,Beta,915,Gamma,916,Delta,917,Epsilon,918,Zeta,919,Eta,920,Theta,921,Iota,922,Kappa,923,Lambda,924,Mu,925,Nu,926,Xi,927,Omicron,928,Pi,929,Rho,931,Sigma,932,Tau,933,Upsilon,934,Phi,935,Chi,936,Psi,937,Omega,945,alpha,946,beta,947,gamma,948,delta,949,epsilon,950,zeta,951,eta,952,theta,953,iota,954,kappa,955,lambda,956,mu,957,nu,958,xi,959,omicron,960,pi,961,rho,962,sigmaf,963,sigma,964,tau,965,upsilon,966,phi,967,chi,968,psi,969,omega,8501,alefsym,982,piv,8476,real,977,thetasym,978,upsih,8472,weierp,8465,image,8592,larr,8593,uarr,8594,rarr,8595,darr,8596,harr,8629,crarr,8656,lArr,8657,uArr,8658,rArr,8659,dArr,8660,hArr,8756,there4,8834,sub,8835,sup,8836,nsub,8838,sube,8839,supe,8853,oplus,8855,otimes,8869,perp,8901,sdot,8968,lceil,8969,rceil,8970,lfloor,8971,rfloor,9001,lang,9002,rang,9674,loz,9824,spades,9827,clubs,9829,hearts,9830,diams,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm,173,shy,233,eacute,237,iacute,243,oacute,250,uacute,193,Aacute,225,aacute,201,Eacute,205,Iacute,211,Oacute,218,Uacute,221,Yacute,253,yacute",
		plugins : "spellchecker,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,flash,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable",
		theme_advanced_buttons1_add : "fontselect,fontsizeselect",
		theme_advanced_buttons2_add : "preview,fullscreen,separator,forecolor,backcolor",
		theme_advanced_buttons2_add_before: "cut,copy,paste,pastetext,pasteword,separator,search,replace,separator",
		theme_advanced_buttons3_add_before : "tablecontrols,separator",
		theme_advanced_buttons3_add : "emotions,iespell,flash,advhr,separator,ltr,rtl,separator,spellchecker",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_path_location : "bottom",
		extended_valid_elements : "hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
		theme_advanced_resize_horizontal : false,
		theme_advanced_resizing : true,
		apply_source_formatting : true,
		spellchecker_languages : "+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv",
		width: "80%",
		height: "250",
		relative_urls : false,
		convert_fonts_to_spans : true,
		elements : 'description'
	});
	
}

function doEdit(id){
	var edit = document.getElementById('addEditAttribute_'+id).checked;
	if(edit == true){
		document.getElementById('attributeValue_'+id).readOnly='';	
	}
	if(edit == false){
		document.getElementById('attributeValue_'+id).readOnly='readOnly';	
	}
}



function pullAttributes(id){
	var url='/adminprodscats?getcategoryattributes';
	var params ='&categoryId='+id;
	url=url+'&categoryId='+id;
	location.href=url;
	//var myAjax = new Ajax.Updater('response', url, {method: 'get', parameters: params, onSuccess:function(){ }} );
}


	function toggelCategoryData(){
		var parentcheck = document.getElementById('parentcheckid').checked;
		if(!parentcheck){
			document.getElementById('catCodeId').style.display='';
			document.getElementById('catParentId').style.display='';
			document.getElementById('catAttributesNewTitleId').style.display='inline';
			document.getElementById('catAttributesAddId').style.display='inline';
			document.getElementById('catAttributesNewId').style.display='inline';
			document.getElementById('catAttributesChooseTitleId').style.display='inline';
			document.getElementById('catBrandsAddId1').style.display='inline';
			document.getElementById('catBrandsAddId2').style.display='inline';
			
		}


		if(parentcheck){
			document.getElementById('catCodeId').style.display='none';
			document.getElementById('catParentId').style.display='none';
			document.getElementById('catAttributesNewTitleId').style.display='none';
			document.getElementById('catAttributesAddId').style.display='none';
			document.getElementById('catAttributesNewId').style.display='none';
			document.getElementById('catAttributesChooseTitleId').style.display='none';
				document.getElementById('catBrandsAddId1').style.display='none';
				document.getElementById('catBrandsAddId2').style.display='none';
			
		}		
	}

function functionCloneMultipleBrands(){
var row1cell1Obj = document.getElementById("brandName");
var row1cell2Obj = document.getElementById("brandCode");
var countertdid = document.getElementById("tdid11");
var children =countertdid.getAttribute('counter');
var maximumItems = countertdid.getAttribute('maximumItems');
if(children != maximumItems){
tr2Obj = document.createElement("TR");
tr2td1Obj = document.createElement("TD");
row2cell1Obj = row1cell1Obj.cloneNode(true);
row2cell1Obj.setAttribute('name', "brandName");
tr2td2Obj = document.createElement("TD");
row2cell2Obj = row1cell2Obj.cloneNode(true);
row2cell2Obj.setAttribute('name', "brandCode");
tr2td1Obj.appendChild(row2cell1Obj);
tr2td2Obj.appendChild(row2cell2Obj);
tr2Obj.appendChild(tr2td1Obj);
tr2Obj.appendChild(tr2td2Obj);
tbl = document.getElementById("originalFormat1");
tbl.appendChild(tr2Obj);
var imagetdid = document.getElementById("tdid11");
var addChild =imagetdid.getAttribute('addImage');
var lessChild =imagetdid.getAttribute('lessImage');
if(children != maximumItems){
		document.getElementById(addChild).style.display="";
		document.getElementById(lessChild).style.display="";
}else{
		document.getElementById(lessChild).style.display="";
		document.getElementById(addChild).style.display="none";
}
children++;
countertdid.setAttribute('counter',children);
countertdid.setAttribute("rowspan",children);
}
}

function functionCloneMultipleFields(fieldId1,propertyName1,fieldId2,propertyName2,fieldId3,propertyName3,rowId,counterId){
		var row1cell1Obj = document.getElementById(fieldId1);
		var row1cell2Obj = document.getElementById(fieldId2);
		var row1cell3Obj = document.getElementById(fieldId3);
		var countertdid = document.getElementById(counterId);
		var children =countertdid.getAttribute('counter');
		var maximumItems = countertdid.getAttribute('maximumItems');
		
		if(children != maximumItems){
			tr2Obj = document.createElement("TR");
			tr2td1Obj = document.createElement("TD");
			row2cell1Obj = row1cell1Obj.cloneNode(true);
			var property = propertyName1+'['+children+']';
			row2cell1Obj.setAttribute('name', property);
			row2cell1Obj.setAttribute('id', property);
			tr2td1Obj.appendChild(row2cell1Obj);
			tr2td2Obj = document.createElement("TD");
			row2cell2Obj = row1cell2Obj.cloneNode(true);
			var property2 = propertyName2+'['+children+']';
			row2cell2Obj.setAttribute('name', property2);
			row2cell2Obj.setAttribute('id', property2);
			row2cell2Obj.checked=false;
	
			tr2td3Obj = document.createElement("TD");
			row2cell3Obj = row1cell3Obj.cloneNode(true);
			var property3 = propertyName3+'['+children+']';
	
			row2cell3Obj.setAttribute('name', property3);
			row2cell3Obj.setAttribute('id', property3);
			row2cell1Obj.setAttribute('colspan', 2);
	
			tr2td1Obj.appendChild(row2cell1Obj);
			tr2td2Obj.appendChild(row2cell2Obj);
			tr2td3Obj.appendChild(row2cell3Obj);
	
		    tr2Obj.appendChild(tr2td1Obj);
		    tr2Obj.appendChild(tr2td2Obj);
			tr2Obj.appendChild(tr2td3Obj);
	
			tbl = document.getElementById(rowId);
			tbl.appendChild(tr2Obj);
	
			children++;
			countertdid.setAttribute('counter',children);
			countertdid.setAttribute("rowspan",children);
			var imagetdid = document.getElementById(counterId);
			var addChild =imagetdid.getAttribute('addImage');
			var lessChild =imagetdid.getAttribute('lessImage');
			if(children != maximumItems){
				document.getElementById(addChild).style.display="";
	    		document.getElementById(lessChild).style.display="";
			}else{
	    		document.getElementById(lessChild).style.display="";
				document.getElementById(addChild).style.display="none";
			}
		}
	
	var returnArray= new Array(property,property2);
	document.getElementById(property).value='';
	document.getElementById(property2).value='';
	document.getElementById(property3).value='';
	return returnArray;
}

function removeClone(counterId,rowid){
		tdObject = document.getElementById(counterId);
		var children =tdObject.getAttribute('counter');
		var addChild =tdObject.getAttribute('addImage');
		var lessChild =tdObject.getAttribute('lessImage');
		if(children != 0){
			tbl = document.getElementById(rowid);
			tbl.removeChild(tbl.lastChild);
			children--;
			tdObject.setAttribute('counter',children);
			
		if(children != 1){
			document.getElementById(addChild).style.display="";
    		document.getElementById(lessChild).style.display="";
		}else{
    		document.getElementById(lessChild).style.display="none";
			document.getElementById(addChild).style.display="";
		}
	}
}

function cloneMultipleFieldsProductForm(fieldId1,propertyName1,fieldId2,propertyName2,fieldId3,propertyName3,fieldId4,propertyName4,
		fieldId5,propertyName5,fieldId6,propertyName6,propertyName7,totalAttributes,rowId,counterId,count1){
			var row1cell1Obj = document.getElementById(fieldId1);
			var row1cell2Obj = document.getElementById(fieldId2);
			var row1cell3Obj = document.getElementById(fieldId3);
			var row1cell4Obj = document.getElementById(fieldId4);
			var row1cell5Obj = document.getElementById(fieldId5+'['+count1+'].'+propertyName5+'[0]');
			var row1cell6Obj = document.getElementById(fieldId6);
			var countertdid  = document.getElementById(counterId);
			var children =countertdid.getAttribute('counter');
			var maximumItems = countertdid.getAttribute('maximumItems');
			var prodAttributeArray= new Array(totalAttributes);
			for(i=0;i<totalAttributes;i++){
				prodAttributeArray[i]=document.getElementById('productAttributeValue['+(children*1-1)+']['+i+']');
			}
			if(children != maximumItems){
				tr2Obj = document.createElement("TR");
				
				tr2td1Obj = document.createElement("TD");
				row2cell1Obj = row1cell1Obj.cloneNode(true);
				var property1 = propertyName1+'['+children+']';
				row2cell1Obj.setAttribute('name', property1);
				row2cell1Obj.setAttribute('id', property1);
				row2cell1Obj.setAttribute('maxlength', '250');

				tr2td1Obj.appendChild(row2cell1Obj);
				
				tr2td2Obj = document.createElement("TD");
				row2cell2Obj = row1cell2Obj.cloneNode(true);
				var property2 = propertyName2+'['+children+']';
				row2cell2Obj.setAttribute('name', property2);
				row2cell2Obj.setAttribute('id', property2);
				row2cell2Obj.setAttribute('maxlength', '10');
				
				
				tr2td3Obj = document.createElement("TD");
				row2cell3Obj = row1cell3Obj.cloneNode(true);
				var property3 = propertyName3+'['+children+']';
				row2cell3Obj.setAttribute('name', property3);
				row2cell3Obj.setAttribute('id', property3);

				tr2td4Obj = document.createElement("TD");
				row2cell4Obj = row1cell4Obj.cloneNode(true);
				var property4 = propertyName4+'['+children+']';
				row2cell4Obj.setAttribute('name', property4);
				row2cell4Obj.setAttribute('id', property4);

				tr2td5Obj = document.createElement("TD");
				tr2td5Obj.setAttribute('id', 'tdImage'+children);
				tr2div5Obj = document.createElement("DIV");
				row2cell5Obj = row1cell5Obj.cloneNode(true);
				var property5 = fieldId5+'['+children+'].'+propertyName5+'[0]';
				tr2div5Obj.setAttribute('id', property5+'div');
				row2cell5Obj.setAttribute('name', property5);
				row2cell5Obj.setAttribute('id', property5);
				
				
				tr2td6Obj = document.createElement("TD");
				row2cell6Obj = row1cell6Obj.cloneNode(true);
				//productImg[0].productImages[0]
				var property6 = propertyName6+'['+children+']';
				row2cell6Obj.setAttribute('name', property6);
				row2cell6Obj.setAttribute('id', property6);
				row2cell6Obj.onclick=function(){addNewFiles(this,children-1,0);};
	
				tr2td1Obj.appendChild(row2cell1Obj);
				tr2td2Obj.appendChild(row2cell2Obj);
				tr2td3Obj.appendChild(row2cell3Obj);
				tr2td4Obj.appendChild(row2cell4Obj);
				tr2div5Obj.appendChild(row2cell5Obj);
				tr2td5Obj.appendChild(tr2div5Obj);
				tr2td6Obj.appendChild(row2cell6Obj);
		
				tr2Obj.appendChild(tr2td1Obj);
				tr2Obj.appendChild(tr2td2Obj);
				tr2Obj.appendChild(tr2td3Obj);
				tr2Obj.appendChild(tr2td4Obj);
				tr2Obj.appendChild(tr2td5Obj);	
				tr2Obj.appendChild(tr2td6Obj);

				for(i=0;i<totalAttributes;i++){
					var tdObj = 'tr2td'+(i*1+6)+'Obj';
					var cellObj = 'row2cell'+(i*1+6)+'Obj';
					tdObj =  document.createElement("TD");
					cellObj = prodAttributeArray[i].cloneNode(true);
					var attribProperty = propertyName7+'['+(children*1)+']['+i+']';
					cellObj.setAttribute('name', attribProperty);
					cellObj.setAttribute('id', attribProperty);
					cellObj.setAttribute('maxlength', '60');
					cellObj.setAttribute('value', ' ');
					tdObj.appendChild(cellObj);
					tr2Obj.appendChild(tdObj);
				}

				tbl = document.getElementById(rowId);
				tbl.appendChild(tr2Obj);
				for(i=0;i<totalAttributes;i++){
					var attribProperty = propertyName7+'['+(children*1)+']['+i+']';
					document.getElementById(attribProperty).value='';
				}
				children++;
				countertdid.setAttribute('counter',children);
				countertdid.setAttribute("rowspan",children);
				var imagetdid = document.getElementById(counterId);
				var addChild =imagetdid.getAttribute('addImage');
				var maximumItems = countertdid.getAttribute('maximumItems');
			    var lessChild =imagetdid.getAttribute('lessImage');
			    if(children != maximumItems){
    				document.getElementById(addChild).style.display="";
    	    		document.getElementById(lessChild).style.display="";
			     }else{
    	    		document.getElementById(lessChild).style.display="";
    				document.getElementById(addChild).style.display="none";
			     }
			}
		var returnArray= new Array(property1,property2);
		document.getElementById(property1).value='';
		document.getElementById(property2).value='';
		document.getElementById(property3).value='';
		document.getElementById(property4).value='';
		document.getElementById(property5).value='';
		
		return returnArray;
}
function addNewFiles(plusobj,count,imgcount){
	var img = document.getElementById('productImg['+count+'].productImages[0]');
	var div5 = document.createElement("DIV");
	var newFile = img.cloneNode(true);
	var property5 = 'productImg['+count+'].productImages['+(++imgcount)+']';
	newFile.setAttribute('id', property5);
	newFile.setAttribute('name', property5);
	div5.setAttribute('id', property5+'div');
    div5.appendChild(newFile);
	var td = document.getElementById('tdImage'+count);
	td.appendChild(div5);
	plusobj.onclick=function(){addNewFiles(plusobj,count,imgcount);};
}
function getCategoryBrands(categoryId){
	location.href = '/adminprodscats?brands&categoryId='+categoryId;
}

function uploadProductFromExcelFormBrands(categoryId){
    if(categoryId != ""){
	   location.href = '/adminprodscats?uploadProductFromExcelFormBrands&categoryId='+categoryId;
	}
}
function updateProductFromExcelFormBrands(categoryId){
	location.href = '/adminprodscats?updateProductFromExcelFormBrands&categoryId='+categoryId;
}

function approveCategory(categoryId,catName){
	try{
	    var confirmMsg="Are you sure to approve category:"+catName;
	    var conf=confirm(confirmMsg);
	    if(conf){
    		var url='/adminprodscats?approvecategory';
    		var params = 'categoryId='+categoryId+'&from=approveItem';
    		if(document.getElementById('tr_'+categoryId) != null){
    		  document.getElementById('tr_'+categoryId).style.display='none';
    		}
    		var myAjax = new Ajax.Updater('responseDiv', url, {method: 'get', parameters: params, onSuccess:function(){  }} );
	   }
	}catch(e){
		//alert(e);
	}	
}
function editAttribute(paramsid,paramsvalue,paramslabel,catname,attributeid){
	try{
		var url='/adminprodscats?editattributechoice';
		var params='paramsid='+paramsid+'&paramsvalue='+paramsvalue+'&paramslabel='+paramslabel+'&catname='+catname+'&attributeid='+attributeid;
		var myAjax = new Ajax.Updater('responseDiv', url, {method: 'get', parameters: params, onSuccess:function(){  }} );
	}catch(e){
		alert(e);
	}	
}
function productinfoAjax(viewType,productId){
	try{
		var url='/productinfo?productinfoajax';
		var params='productId='+productId+'&view='+viewType;
		var myAjax = new Ajax.Updater('productinfoajax', url, {method: 'get', parameters: params, onSuccess:function(){  }} );
	}catch(e){
		alert(e);
	}	
}
function selectBrand(cat){
    if(cat != ""){
         try{
    		var url='/adminprodscats?brands';
    		var params='categoryId='+cat+'&brandAjax=true';
    		var myAjax = new Ajax.Updater('brandlist', url, {method: 'get', parameters: params, onSuccess:function(){  }} );
    	}catch(e){
    		alert(e);
    	}	
	}
}
function activateChoice(cid){
try{
        var id='id'+cid;
        var activate=false;
        if(document.getElementById(id).checked == true){
            activate=true;
        }
		var url='/adminprodscats?activateattributechoice';
		var params='cid='+cid+'&activate='+activate;
		var myAjax = new Ajax.Updater('responseDiv', url, {method: 'get', parameters: params, onSuccess:function(){  }} );
	}catch(e){
		alert(e);
	}	
}
function addAttChoice(ch,attributeId,idval){
alert("ch==="+ch+"attributeId==="+attributeId+"idval=="+idval)
}
function deleteAttribute(paramsid){
	try{
		var url='/adminprodscats?deleteattributechoice';
		var params='paramsid='+paramsid;
		var myAjax = new Ajax.Updater('responseDiv', url, {method: 'get', parameters: params, onSuccess:function(){  }} );
	}catch(e){
		alert(e);
	}	
}
function loadCity(stateId){
try{
		var url='/address?loadcity';
		var params='stateId='+stateId;
		var myAjax = new Ajax.Updater('cityDiv', url, {method: 'get', parameters: params, onSuccess:function(){  }} );
	}catch(e){
		alert(e);
	}	
}
function loadShipLoad(cityName){
try{
		var url='/address?loadship';
		var params='cityName='+cityName;
		var myAjax = new Ajax.Updater('shipPriceId', url, {method: 'get', parameters: params, onSuccess:function(){  }} );
	}catch(e){
		alert(e);
	}	
}
function approveParentCategory(categoryId){
	try{
		var url='/adminprodscats?approveparentcategory';
		var params = 'categoryId='+categoryId+'&from=approveItem';
		window.location='/adminprodscats?approveparentcategory&'+params;
		//var myAjax = new Ajax.Updater('responseDiv', url, {method: 'get', parameters: params, onSuccess:function(){  }} );
	}catch(e){
		//alert(e);
	}	
}

function approveProduct(productId,itemId,productName){
	try{
	       var confirmMsg="Are you sure to approve product:"+productName;
    	    var conf=confirm(confirmMsg);
    	    if(conf){
        		var url='/adminprodscats?activateProduct';
        		var params = 'id='+productId+'&from=approveItem&itemId='+itemId;
        		var trId = 'tr_'+productId;
        		document.getElementById(trId).style.display='none';
        		var myAjax = new Ajax.Updater('responseDiv', url, {method: 'get', parameters: params, onSuccess:function(){ 
        		  try{document.getElementById(trId).style.display='none';}catch(e){} 
        		}} );
		  }
	}catch(e){
	}	
}

function deleteParentCategory(categoryId){
	var confrm=confirm('Are you sure to delte this category?');
	if(!confrm){
		return false;
	}
	var url='/adminprodscats?deleteParentCategory';
	var params = 'id='+categoryId;
	var trId = 'cat_'+categoryId;
	var myAjax = new Ajax.Updater('responseDiv', url, {method: 'get', parameters: params, onSuccess:function(){ try{}catch(e){} }} );
}
function changeImage(imageId){
var url='/productinfo?changeImage';
	var params = 'id='+imageId;
	var myAjax = new Ajax.Updater('imgDiv', url, {method: 'get', parameters: params, onSuccess:function(){ try{}catch(e){} }} );
}
function deactivateParentCategory(categoryId){
	var confrm=confirm('Are you sure to deactivate this category?');
	if(!confrm){
		return false;
	}
	var url='/adminprodscats?dectivateParentCategory&';
	var params = 'id='+categoryId;
	var trId = 'cat_'+categoryId;
	window.location=url+params;
	//var myAjax = new Ajax.Updater('responseDiv', url, {method: 'get', parameters: params, onSuccess:function(){ try{}catch(e){} }} );
}

function selectType(val){
	document.getElementById('selectCategory').style.display='none';
	document.getElementById('selectProduct').style.display='none';
	document.getElementById('selectForSearch').value=val;
	if(val == 1){
		document.getElementById('form').submit()
	}	
	if(val == 2){
		document.getElementById('selectCategory').style.display='';
		document.getElementById('selectProduct').style.display='';
		document.getElementById('sumitProduct').style.display='';
		document.getElementById('msg').style.display='none';
	}	
	if(val == 3){
		document.getElementById('form').submit()
	}
	
}	

function submitSelect(){
		if(document.getElementById("categorySelect").value==0){
			alert('Please select category');
			return false;
	}
	return true;
}
	
function enableButton(value){
	if(value!=''){
		document.getElementById('submitButoonId').disabled=false;
	}
	else{
		document.getElementById('submitButoonId').disabled=true;
	}
}
function checkAlphaNumericValue(e){
		var unicode=e.charCode? e.charCode : e.keyCode;
		
		if(unicode >= 48 && unicode <=57 
			||unicode == 8 || unicode == 9 || unicode == 32 ||  e.charCode ==0
			|| unicode >= 65 && unicode <= 90 ||unicode >= 97 && unicode <= 122 ){
			return true;
		}
		return false;
	}
function checkNumericValue(e){
        
		var unicode=e.charCode? e.charCode : e.keyCode;
		if(unicode >= 48 && unicode <=57 || e.charCode ==0
			||unicode == 8 || unicode == 9 ){
			return true;
		}
		return false;
	}
function checkSpace(e){
        var unicode=e.charCode? e.charCode : e.keyCode;
		if(unicode == 32 ){
			return false;
		}
		return true;
	}
function checkNumericValueWithDecimal(e,obj){
        
		var unicode=e.charCode? e.charCode : e.keyCode;
		var value=obj.value+"";
        if(value.indexOf(".") > -1 && unicode == 46){
            return false;
        }
		if(unicode >= 48 && unicode <=57 
			||unicode == 8||unicode == 46 || unicode == 9 ||  e.charCode ==0){
			return true;
		}
		return false;
	}	
function checkAlphaNumericwithunderscore(e){
var unicode=e.charCode? e.charCode : e.keyCode;
		if(unicode >= 48 && unicode <=57 
			||unicode == 8 || unicode == 9 ||unicode == 32||  e.charCode ==0
			|| unicode >= 65 && unicode <= 90 ||unicode >= 97 && unicode <= 122 || unicode == 95 ){
			return true;
		}
		return false;
}
