
function display_comment(display_val,ispageload)
{
	if(document.getElementById('comment_block'))
	{		
		if(document.getElementById('comment_block').style.display!='none')
		{
			display_val='none';
		}
		document.getElementById('comment_block').style.display=display_val;
		//document.getElementById('author_msg_block').style.display=display_val;
		//document.getElementById('reply_msg_block').style.display=display_val;
		document.getElementById('msg_block').style.display=display_val;
	}
}
function SendToMailList()
{
	idprod = getValue('idProduct');
	location.href = "index.php?task=sendmaillist&id="+idprod;	
}

function nextproduct(id)
{
	location.href = "index.php?task=home&id="+id;
}


function AddSubscribe()
{
	idprod = document.getElementById('idProduct').value;
	email = document.getElementById('email_subscribe').value;	
	
	if (email=='' || email=='Enter your email here')
	{
		msg('susmsg','','Put your email...');	
		return;
	}
	
	if(!validateEmail(getCtrl('email_subscribe'), 'susmsg')) {
		return;
	}
	
	var url = "index.php?task=subscribe&mode=saveAjax&rrt=xml&pid="+idprod+"&email="+email;

	var ajax = new AJAXInteraction (url, displaySubscribe);
	ajax.doGet();
}
function displaySubscribe(response)
{

	try{
	  st = response.getElementsByTagName("status")[0].firstChild.data;
	  st = "ok";
	  if (st=="ok")
	  {
		document.getElementById('Subscribe').disabled="disabled";
//		msg ('susmsg','', 'Thank you...');
//		setValue("susmsg","Thank you...");
		saythank = document.getElementById('lbl_thank_subscribe').value;
		setValue('email_subscribe', saythank);
	  }
	  else 
	  {
	  }
	}
	catch(er)
	{
	  alert (er.message);
	}

}
function toggle(divname, force) {
	
	try{
	var dx = document.getElementById(divname).style;
	//alert (force);
	if(typeof(force)!="undefined"){ 

		dx.display =force;
	} else {
		if (dx.display == 'block'){
			dx.display = 'none';
		}else{
			dx.display = 'block';
		}
	}
	} 
	catch(er)
	{
		// do nothing	
	}
}
function closePic(){
	toggle('productgrid','none');
	toggle('rightside','block');
}

//START ADDED BY BIEN: 2008-03-03
function changeOrder(pg, searchby, searchfor) 
{
	var data = "0" + encodeURIComponent(pg);
	//alert(data);
	//alert(data);
		url = '?task=picturelist&mode=show&subtask='+data+'&rrt=block';
		var ajax = new AJAXTextAction (url, confirmChangePicture);
		ajax.doGet();
}
function nextPicture(or)
{
	changePicture(or);
	/*var pg=parseInt(document.getElementById("ppg").value);
	//alert(pg);
	if(or==1)//previous	
	changePicture(pg-1);
	else// next	
	changePicture(pg+1);*/
}
function searchitems()
{
	strsearch = document.getElementById("search").value
	if (strsearch.length > 1)
	changePicture('-1', 'search',strsearch);
}
//END 
function changePicture(pg, searchby, searchfor) 
{
	//alert(pg +"  "+picsLoaded +"  "+ searchby+"  "+ encodeURIComponent(searchfor));
	if (pg ==0 && picsLoaded == true)
	{
		//some query already loaded the pics, just exchange, if new query, it will change again..
		toggle('rightside','none');
		toggle('productgrid','block');
	}
	else
	{
		var data = "ppg=" + encodeURIComponent(pg);
		url = '?task=picturelist&mode=show&ppg='+pg+'&rrt=block&'+searchby+'='+encodeURIComponent(searchfor);
		var ajax = new AJAXTextAction (url, confirmChangePicture);
		ajax.doGet();
	}
}
// SET A GLOBAL VAR
var picsLoaded = false;
function confirmChangePicture(response)
{ 
//	setValue("productgrid",response);
	
	try
	{
		var elem = document.getElementById('productgrid');
		elem.innerHTML = response;
		//alert(response);
		toggle('rightside','none');
		toggle('productgrid','block');
		picsLoaded = true;
		return; 	
	} catch (er)
	{
	}
}
