function setSelectItem(selectitem,selectvalue)
{
   for(i=0;i<selectitem.length;i++){
   
   if(selectitem[i].value == selectvalue)
    selectitem[i].selected =true;

	}
}

function getid(ele)
{
	return document.getElementById(ele) 
}

function alphanumeric(alphane)
{
	var numaric = alphane;
	for(var j=0; j<numaric.length; j++)
		{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
		  {
		  }
		else	{
			 return false;
		  }
		}
 return true;
}

function scalesize(item, width, height)
{	
	var itemwidth =0;
	var itemheight = 0;
	
	if ((item.src!=null)&&((item.width==0)||(item.height == 0)))
	{	abc = new Image();
		abc.src = item.src;
		itemwidth = abc.width;
		itemheight = abc.height;
	}else
	{
		itemwidth = item.width;
		itemheight = item.height;
	}
	
	if ((width/height) >= (itemwidth/itemheight))
	{
			if(itemheight>height)
		 		item.height=height;
		 	else if (itemheight == 0)
		 		item.height=height;
			 	
		 		item.style.display="inline";
		 		
		 		return;
		
	}else
	{
		if(itemwidth>width)
		 		item.width=width;
		  	else if (itemwidth == 0)
		 		item.width=width;
		 		
		 		item.style.display="inline";
			return;
			
	}
	

}


function changepagedivpos()
{
if (screen.width > 1024)
{
document.getElementById("pagediv").style.left = (screen.width -1024)/2;
//if (document.getElementById("pagediv").style.display == "NONE")
document.getElementById("pagediv").style.display="inline";
return;
}
else
{
document.getElementById("pagediv").style.left = 0;
//if (document.getElementById("pagediv").style.display == "NONE")
document.getElementById("pagediv").style.display="inline";
return;
}
}

function savepos()
{
	
	
	var abc = document.freeobject.foquantity;
	var poststr ="quantity="+document.getElementById("foquantity").value;
	
	
	for(var i = 0; i < 100; i++)
	{
		if (document.getElementById("fo_"+i) != null)
		{
		document.getElementById("fo_"+i+"_x").value = document.getElementById("fo_"+i).style.left;
		poststr =poststr+"&fo_"+i+"_x="+document.getElementById("fo_"+i+"_x").value;
		document.getElementById("fo_"+i+"_y").value = document.getElementById("fo_"+i).style.top;
		poststr =poststr+"&fo_"+i+"_y="+document.getElementById("fo_"+i+"_y").value;
		
		document.getElementById("fo_"+i+"_width").value = document.getElementById("fo_"+i).width;
		poststr =poststr+"&fo_"+i+"_width="+document.getElementById("fo_"+i+"_width").value;
		document.getElementById("fo_"+i+"_height").value = document.getElementById("fo_"+i).height;
		poststr =poststr+"&fo_"+i+"_height="+document.getElementById("fo_"+i+"_height").value;
		
		poststr =poststr+"&fo_"+i+"_name="+document.getElementById("fo_"+i+"_name").value;
		poststr =poststr+"&fo_"+i+"_type="+document.getElementById("fo_"+i+"_type").value;
		}
	}
	
	var xmlhttp; 
	if (window.XMLHttpRequest) {
	xmlhttp = new XMLHttpRequest();
	} else {
	try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {
	try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {
	xmlhttp = null; } }
	}
		
	if (xmlhttp != null)
	 {
		 try {
	// alert(poststr);
	//xmlhttp.onreadystatechange = feedbackhandler(xmlhttp); 
	xmlhttp.open("POST","/webservice/servlet/fosaveposition" ,true);
	//xmlHttp.setRequestHeader("context-type","text/xml;charset=utf-8");
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
     xmlhttp.send(poststr);
     } catch (e) { alert(e.toString()); }
    // xmlhttp.onreadystatechange = feedbackhandler(xmlhttp); 
	
 }
 
 	 	//document.freeobject.submit();

}


function gethttprequest()
{
	var xmlhttp2;
	if (window.XMLHttpRequest) {
	xmlhttp2 = new XMLHttpRequest();
	} else {
	try { xmlhttp2 = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {
	try { xmlhttp2 = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {
	xmlhttp2 = null; } }
	}
	
	return xmlhttp2;
}

function sendAjax(xmlhttp2,url,poststr)
{
		
	if (xmlhttp2 != null)
	 {
		 try {
	// alert(poststr);
	//xmlhttp.onreadystatechange = feedbackhandler(xmlhttp); 
	xmlhttp2.open("POST",url ,true);
	//xmlHttp.setRequestHeader("context-type","text/xml;charset=utf-8");
	xmlhttp2.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	
     xmlhttp2.send(poststr);
   
     } catch (e) { alert(e.toString()); }
    // xmlhttp.onreadystatechange = feedbackhandler(xmlhttp); 
	
 }
}

function feedbackhandler(xmlhttp)
 {
      if (xmlhttp.readyState == 4) {
         if ( xmlhttp.status == 200) {
            alert("success");
         } else {
            alert("failed");
         }
      }else alert("failed");
      
	}
	
function callurl(urlsite)
{
	if (!window.newWin || newWin.closed) 
		newWin=window.open(urlsite,'');
	else newWin.location = urlsite;
}
	 
function fiselect(fieldname,selectitem)
{
	
	var currentwidth =0;
	var currentheight = 0;
	var comingwidth =0;
	var comingheight = 0;
	if (document.getElementById(fieldname).value.length > 1)
	{
				
		if (document.getElementById("o_"+document.getElementById(fieldname).value)!= null)
		{
		currentwidth = document.getElementById("o_"+document.getElementById(fieldname).value).width; 
		currentheight = document.getElementById("o_"+document.getElementById(fieldname).value).height;
		comingwidth = currentwidth*100/150;
		comingheight = currentheight*100/150;
		document.getElementById("o_"+document.getElementById(fieldname).value).width =comingwidth;
		document.getElementById("o_"+document.getElementById(fieldname).value).height =comingheight;
		}
	}
		
	selectitem.width = selectitem.width*150/100;
	selectitem.height = selectitem.height*150/100;
	
	document.getElementById(fieldname).value = selectitem.name.substring(2, selectitem.name.length+1);
	
	
}
