//#---------------------------------------------------------------------#
//#	DESCRIPTION		:	basic.js										#
//#	AUTHOR			:	Kithsir Lihinikaduwa							#
//# CREATE DATE		:	JAN 26, 2008									#
//#	LAST CHANGED	:	JAN 26, 2008									#
//#---------------------------------------------------------------------#



var ajax = new GLM.AJAX();

function showDv(surl,dv){
	//alert(surl);
	//alert(dv);
	ajax.callPage(surl,dv);
}

function eBBsearch(cde){
	var eBBVal;
	var url;
	eBBVal	=	document.getElementById('eBBSearch').value;
	url		=	"http://www.ebingbong.com/searchui/basic.php";
	switch (cde)
	{
		case 0:
			url	=	"http://www.ebingbong.com/searchui/showResults.php?lg=0&enc=utf-8&rank=1&age=0&cclic=0&ftype=&safe=3&display=1%3A10&cat=&ftype=&box="+eBBVal+"&where=0&q=%2B"+eBBVal+"&styp=0&domain=&bi=";
		break;
		case 1:
			url	=	"http://www.ebingbong.com/searchui/image/showResults.php?lg=0&enc=utf-8&rank=1&age=0&cclic=0&where=0&ftype=&safe=3&display=1%3A12&box="+eBBVal+"&q=%2B"+eBBVal+"&styp=0&domain=";
		break;
		case 2:
			url	=	"http://www.ebingbong.com/searchui/vrecommends/showResults.php?lg=0&enc=utf-8&safe=3&age=0&where=0&cclic=0&ftype=&rank=1&display=1%3A10&box="+eBBVal+"&duration=all&q=%2B"+eBBVal+"&styp=0&domain=";
		break;
		case 3:
			url	=	"http://www.ebingbong.com/searchui/nrecommends/showResults.php?lg=0&enc=utf-8&safe=3&age=0&where=0&cclic=0&ftype=&rank=1&display=1%3A10&box="+eBBVal+"&q=%2B"+eBBVal+"&styp=0&domain=";
		break;
		
	
	}
	document.location.href	=	url;
}

function clearDv(dv){
	document.getElementById(dv).innerHTML	=	'';
}
function textCounter(field,cntfield,maxlimit) {
	if (field.value.length > maxlimit){
		field.value = field.value.substring(0, maxlimit);
	}
	else{
		cntfield.value = maxlimit - field.value.length;
	}
}


function changeClass(cname,name){
	document.getElementById(name).className=cname;
}


function saveComment(thisPage,obj){
	var url;
	var rate;
	var i;
	rate	=	0;
	
	
		for (i=0;i<5;i++ )
		{
			if (obj.RATE[i].checked==true)
			{
				rate	=	obj.RATE[i].value;
				
			}
		}
	
	url	=	thisPage+"&RATE="+rate+"&COMMENT="+obj.COMMENT.value;
	showDv(url,showComment);
}

function saveUTVideo(link,dv){
	var video;
	video	=	UTForm.pvideo.value;
	link= link+"&pvideo="+video;
	showDv(link,dv);
}


function showMenu(response){	
	document.getElementById('menu').innerHTML	=	response;
}
function showBrows(response){
	document.getElementById('brows').innerHTML	=	response;
}
function showFriends(response){
	document.getElementById('friends').innerHTML	=	response;
}
function showDetails(response){
	document.getElementById('details').innerHTML	=	response;
}
function showContact(response){
	document.getElementById('contact').innerHTML	=	response;
}
function showPicture(response){
	document.getElementById('picture').innerHTML	=	response;
}
function showPic(response){
	document.getElementById('pic').innerHTML	=	response;
}
function showVideo(response){
	document.getElementById('video').innerHTML	=	response;
}
function showComment(response){
	document.getElementById('comment').innerHTML	=	response;
}
function showMess(response){

	document.getElementById('mess').innerHTML	=	response;
}
function showBody(response){
	document.getElementById('body').innerHTML	=	response;
}
function showTitle(response){
	document.getElementById('title').innerHTML	=	response;
}
function showAbout(response){
	document.getElementById('about').innerHTML	=	response;
}
function showInfo(response){
	document.getElementById('info').innerHTML	=	response;
}
function showRate(response){
	document.getElementById('rate').innerHTML	=	response;
}
function showCat(response){
	//alert(response);
	document.getElementById('cat').innerHTML	=	response;
}
function showMcatdv(response){
	document.getElementById('mcatdv').innerHTML	=	response;
}
function showThead(response){
	document.getElementById('thead').innerHTML	=	response;
}
function showFeature(response){
	document.getElementById('feature').innerHTML	=	response;
}
function showDetails(response){
	document.getElementById('details').innerHTML	=	response;
}

function showBRate(response){
	document.getElementById('brate').innerHTML	=	response;
}

function getSWidth(){
	var swidth;
	swidth	=	screen.width;
	if (swidth<780)
	{
		swidth	=	770;
	}
	else if (swidth>1600){
		swidth	= 1500;
	}
	else{
		swidth	= swidth-40;
	}
	document.getElementById('mtbody').style.width 	=	swidth+"px";
}

function savePascat(code,link,ftot){
	var MCAT1;
	var	SCAT1;
	var linkUrl;
	var SCATNAME;


	MCAT1	=	meForm.MCAT.value;
	SCAT1	=	meForm.SCAT.value;
	SCATNAME=	meForm.PASCAT.value;
	linkUrl	=	link+"&MCAT="+MCAT1+"&SCAT="+SCAT1+"&PASCAT="+SCATNAME+"&FTOTAL="+ftot;

	for (count=0;count<ftot;count++ )
	{	
		linkUrl	=	linkUrl	+ "&FEA_"+count+"=" +document.meForm.elements["FEA[]"][count].value;
	}

	
	
	if (code==1)
	{
		showDv(linkUrl,showMcatdv);
		document.getElementById('cat').innerHTML	=	'';
	}
	else{
		showDv(linkUrl,showCat);
	}
}

function checkUpload(){
	var res;
	var output;
	var des;
	var pname;
	var rimg;

	output	=	"Please correct followings \n\n";
	res		=	true;
	pname	= document.meForm.PNAME.value;	
	if (pname.length<1)
	{
		res		=	false;
		output	=	output+"* Product Name \n";
	}
	
	rimg	= document.meForm.RIMG.value;	
	if (rimg.length<1)
	{
		res		=	false;
		output	=	output+"* Word Verification \n";
	}
	if (res==false)
	{
		alert(output);
	}
	return res;
}


function enableSave(value){
	var len;
	len=value.length;
	if (len>2)
	{
		meForm.save.disabled=false;
	}
	else{
		meForm.save.disabled=true;
	}
}

function saveUndo(link){
	var val;
	var linkUrl;
	val	=	meForm.EXP.value;
	if (val=='')
	{
		alert('Invalid explanation');
	}
	else{
		linkUrl	=	link +'&SHOW=T&EXP='+ val;
		showDv(linkUrl,showInfo);
	}
}

function showRStar(i,link,page_path){
	var k;
	var res;
	var img;
	
	for (k=1;k<6 ;k++ )
	{
		if (k>i)
		{
			img	=	"starb.gif";
		}
		else{
			img	=	"fstar.gif";
		}
		document.getElementById('mstart_'+k).src=page_path+'images/star/'+img;
	}
}

function submitRate(link,link1){
	showDv(link,showRate);
	showDv(link1,showBRate);
}

