
function doAjax(strURL,strPostData,strObj,method,strProgressMessage,nTime,fn) {
    var xmlHttpReq = false;
    var self = this;
	var msg="";
    // Mozilla/Safari
	
	www=(window.location.href.toLowerCase().indexOf("//www.")>0)?"http://www.":"http://";
	strURL=strURL.replace("http://",www);
	updateMessage(strObj,strProgressMessage);

    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open(method, strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
		
        if (self.xmlHttpReq.readyState == 4) 
		{
			//alert(self.xmlHttpReq.responseText);
			msg=(strObj+"~|~"+self.xmlHttpReq.responseText).split("~|~");
			
			for (i=0;i<msg.length;i=i+2)
			{
				
				updateMessage(msg[i],msg[i+1]);
			}
			
			switch(fn)
			{
				case "renderProductOptions":				
				
					removeItemRow();
					updateMessage(strObj,"Inventory updated successfully!");
					renderProductOptions(self.xmlHttpReq.responseText);
					
					break;
				case null:
					break;
			}
			
			if (nTime>0) setTimeout("hide('"+strObj+"');",nTime);
        }
		else
		{
			//alert(self.xmlHttpReq.readyState);
		}
    }
	
    self.xmlHttpReq.send(strPostData);
}

function removeItemRow()
{
  var tbl = document.getElementById('tblGroups');
  var lastRow = tbl.rows.length;
  var iteration = lastRow;
  for (i=3;i<iteration;i++)
  {
  	tbl.deleteRow(tbl.rows.length-1);
	
  }

}


function updateMessage(obj,str)
{
	show(obj);	
	document.getElementById(obj).innerHTML=str;
}

function showHide(id)
{
	if (document.getElementById(id).style.display=='')
		document.getElementById(id).style.display='none';
	else
		document.getElementById(id).style.display='';
		
}
function show(id)
{
		document.getElementById(id).style.display='block';
		
}
function hide(id)
{
		document.getElementById(id).style.display='none';
}

function xmlhttp1(strURL,strupdate) 
{    
	//alert(strURL+"-------------"+strupdate) 
	var xmlHttpReq = false;
    var self = this;
	
    // Mozilla/Safari
    if (window.XMLHttpRequest) 
	{
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) 
	{
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() 
	{
      if (self.xmlHttpReq.readyState == 4) 
	  {
	//alert(self.xmlHttpReq.responseText);
		updatepage(self.xmlHttpReq.responseText,strupdate);
	  }
    }	
    self.xmlHttpReq.send('');
}
function updatepage(str,strnewdata)
{
	splitstr(str, "document.getElementById('" + strnewdata + "').options");
}
function splitstr(argstr, argctrl)
{
	var ctrl = eval(argctrl)
    var prezar = argstr.split("|");
    argctrl.length = 0;
	clearcombo(ctrl);
    for (o=0; o < prezar.length-1; o++)
    {
	  splitarr = prezar[o].split(":");
      ctrl[ctrl.length] = new Option(splitarr[1], splitarr[0]);
    }
}
function clearcombo(argctrl)
{
  for (var i=argctrl.length-1; i>=0; i--)
  {
    argctrl[i] = null;
  }
}


function showdiv1(val)
{
if(val==0)
{
document.getElementById('display_msg').style.display='none';
}
else
{
document.getElementById('display_msg').style.display='';
}

}
function hidearticle(id)
				{ 
					if (document.getElementById)
					{
					obj = document.getElementById('view'+id);
						if (obj.style.display == "")
						{ 
							obj.style.display = "none";
							document.getElementById('toga'+id).innerHTML="<strong><font color='#009933'>show..</font></strong>";
						} else {
							
							obj.style.display = "";
							document.getElementById('toga'+id).innerHTML="<strong><font color='#FF0000'>hide..</font></strong>";
						}
						
					}
				}
				function showarticle(id)
				{
					if (document.getElementById)
					{
					obj = document.getElementById(id);
						if (obj.style.display == "")
						{ 
							obj.style.display = "none";
							document.getElementById('addnewsubs').value="            ADD NEW SUBSCRIPTION         ";
						} else {
							
							obj.style.display = "";
							document.getElementById('addnewsubs').value="                         CANCEL                      ";
						}
						
					}
				}

function showarticles(id)
				{
					if (document.getElementById)
					{
					obj = document.getElementById(id);
					obj.innerHTML=document.getElementById("parentdiv").innerHTML;
					obj.style.display="";	
					}
				}
				
				function testing()
{

document.getElementById('pdf_bgcolor').value=artabus;

val=document.getElementById('pdf_bgcolor').value;
document.getElementById('vw1').style.backgroundColor=val
obj=document.getElementById('view1')
 if(obj.style.display==""){
 obj.style.display="none";
 }
 else {
 obj.style.display="";
}}

function test2()
{

document.getElementById('pdf_head1').value=artabus;
val=document.getElementById('pdf_head1').value;
document.getElementById('vw2').style.backgroundColor=val
obj=document.getElementById('view2')
 if(obj.style.display==""){
 obj.style.display="none";
 }
 else {
 obj.style.display="";
}
}
function test3()
{
document.getElementById('pdf_head2').value=artabus;
val=document.getElementById('pdf_head2').value;
document.getElementById('vw3').style.backgroundColor=val
obj=document.getElementById('view3')
 if(obj.style.display==""){
 obj.style.display="none";
 }
 else {
 obj.style.display="";
}
}
function test4()
{
obj=document.getElementById('view4')
 if(obj.style.display==""){
 obj.style.display="none";
 }
 else {
 obj.style.display="";
}
document.getElementById('pdf_maintext').value=artabus;
val=document.getElementById('pdf_maintext').value;
document.getElementById('vw4').style.backgroundColor=val
}
function test5()
{
document.getElementById('pdf_testlink').value=artabus;
val=document.getElementById('pdf_testlink').value;
document.getElementById('vw5').style.backgroundColor=val
obj=document.getElementById('view5')
 if(obj.style.display==""){
 obj.style.display="none";
 }
 else {
 obj.style.display="";
}
}
	function hideshow(id)
				{ 
					if (document.getElementById)
					{
					obj = document.getElementById(id);
						if (obj.style.display == "")
						{ 
							obj.style.display = "none";
							document.getElementById('s'+id).innerHTML="<strong><font color='#0033FF'>Show</font></strong>";
						} else {
							
							obj.style.display = "";
							document.getElementById('s'+id).innerHTML="<strong><font color='#0033FF'>Hide</font></strong>";
						}
						
					}
				}
				
				function showthisdiv(id)
				{ 
					if (document.getElementById)
					{
					obj = document.getElementById(id);
						if (obj.style.display == "none")
						{ 
							obj.style.display = "";
							
						} 
						
					}
				}
				function showthisdiv77(id)
				{ 
					if (document.getElementById)
					{
					obj = document.getElementById(id);
						if (obj.style.display == "")
						{ 
							obj.style.display = "none";
							
						} 
						
					}
				}
	function showthisdiv5(id)
				{ 
			//alert(id);
					if (document.getElementById)
					{
					obj = document.getElementById('view'+id);
					//lin=document.getElementById('png'+id);
						if (obj.style.display == "")
						{ 
							obj.style.display = "none";
						//	lin.value="+";
						document.getElementById("png"+id).innerHTML="<img src='fat-images/add.png' alt='click to show details' title='Click to show more details' />";
						} else {
							
							obj.style.display = "";
							//lin.value="-";
							document.getElementById("png"+id).innerHTML="<img src='fat-images/minus.png' alt='click to hide details' title='Click to hide more details'  />";
							
						}
						
					}
				}
			
			
				function showthisdiv_fav(id)
				{ 
			//alert(id);
					if (document.getElementById)
					{
					obj = document.getElementById('view'+id);
					//lin=document.getElementById('png'+id);
						if (obj.style.display == "")
						{ 
							obj.style.display = "none";
						
						} else {
							obj.style.display = "";
								}
						
					}
				}
						
							function showthisdiv1(id)
				{ 
			//alert(id);
					if (document.getElementById)
					{
					obj = document.getElementById('view'+id);
					lin=document.getElementById(id);
						if (obj.style.display == "")
						{ 
							obj.style.display = "none";
							lin.innerHTML="SHOW DETAIL";
						} else {
							
							obj.style.display = "";
							lin.innerHTML="HIDE DETAIL";
							
						}
						
					}
				}
				
				
function addNewFavList(){
	var ids="";
	for(i=0;i<document.myform.elements["deal_id[]"].length;i++){
		if(document.myform.elements["deal_id[]"][i].checked){
			ids += ','+document.myform.elements["deal_id[]"][i].value;
		}
	}
	var listname=document.myform.newfavlistname.value;
	if(listname.length<1){
		alert("You did not enter a listname");
		document.myform.newfavlistname.focus();
		return;
	}
	if(ids.length<1){
		alert("You did not select any deal");
		return;
	}
	addToNewFavList(listname, ids, document.myform);
}

function addNewFavListfromcompare(){
	var ids="";
	for(i=0;i<document.form1.elements["deal_check[]"].length;i++){
		if(document.form1.elements["deal_check[]"][i].checked){
			ids += ','+document.form1.elements["deal_check[]"][i].value;
		}
	}
	var listname=document.form1.newfavlistname.value;
	if(listname.length<1){
		alert("You did not enter a listname");
		document.form1.newfavlistname.focus();
		return;
	}
	if(ids.length<1){
		alert("You did not select any deal");
		return;
	}
	addToNewFavList(listname, ids, document.form1);
}

function addToNewFavList(listname, ids, frm){
	strURL='addtonewfavlist.php?listname='+listname+'&ids='+ids
	var xmlHttpReq = false;
    var self = this;
    if (window.XMLHttpRequest) 
	{
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
	{
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }

	self.xmlHttpReq.open('GET', strURL, true);
    self.xmlHttpReq.onreadystatechange = function() 
	{
      if (self.xmlHttpReq.readyState == 4) 
	  {
		var ans=self.xmlHttpReq.responseText;
		if(ans=='ok'){
			document.getElementById('newfavlistresult').innerHTML='Favlist with selected results successfully added.';
			frm.newfavlistname.value='';
			var optn = document.createElement("OPTION");
			optn.text = frm.newfavlistname.value;
			optn.value = frm.newfavlistname.value;
			frm.favlist.options.add(optn);
			document.getElementById('txtNewList').style.display='none';
			//checkedAll();
		}
		else{
			document.getElementById('newfavlistresult').innerHTML=ans;
		}
	  }
    }	
    self.xmlHttpReq.send('');
}
function addfav(id)
				{ 
					if (document.getElementById)
					{
					obj = document.getElementById(id);
						if (obj.style.display == "")
						{ 
							obj.style.display = "none";
							
						} else {
							
							obj.style.display = "";
							
						}
						
					}
				}
				
				
				
function callAjax(strURL,strPostData,thefunction) {
    var xmlHttpReq = false;
    var self = this;
	var msg="";
    // Mozilla/Safari
	
	www=(window.location.href.toLowerCase().indexOf("//www.")>0)?"http://www.":"http://";
	strURL=strURL.replace("http://",www);

    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
		
        if (self.xmlHttpReq.readyState == 4) 
		{
			thefunction(self.xmlHttpReq.responseText);
		}
		else
		{
			//alert(self.xmlHttpReq.readyState);
		}
    }
	
    self.xmlHttpReq.send(strPostData);
}				

				
function callImgAjax(strURL,divId) {
    var xmlHttpReq = false;
    var self = this;
	var msg="";
    // Mozilla/Safari
	
	/*www=(window.location.href.toLowerCase().indexOf("//www.")>0)?"http://www.":"http://";
	strURL=strURL.replace("http://",www);*/

    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, false);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
		
        if (self.xmlHttpReq.readyState == 4) 
		{
			document.getElementById("img_desc").innerHTML = self.xmlHttpReq.responseText;
		}
		else
		{
			//alert(self.xmlHttpReq.readyState);
		}
    }
	
    self.xmlHttpReq.send(null);
}				



function callImgAjax_desc(strURL,divId) {
    var xmlHttpReq = false;
    var self = this;
	var msg="";
    // Mozilla/Safari
	
	/*www=(window.location.href.toLowerCase().indexOf("//www.")>0)?"http://www.":"http://";
	strURL=strURL.replace("http://",www);*/

    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
		
        if (self.xmlHttpReq.readyState == 4) 
		{
			document.getElementById("img_desc").innerHTML = self.xmlHttpReq.responseText;
		}
		else
		{
			//alert(self.xmlHttpReq.readyState);
		}
    }
	
    self.xmlHttpReq.send(null);
}				



