// JavaScript Document
var msg = "<center><br><br><img src=\'images/anim.gif\' ><br>Please Wait...</center><br><br>";
var query = '';


function show_sub_categories(catid)
{	
	query = 'ctid='+catid;
	callAHAH('GET','sub_categories.php',query,'subcat_div','<div id=\'welcome\' class=\'post\'><h2 class=\'title_\'><span>Loading...</span></h2>'+msg+'</div>');		
}

function show_terms()
{	
	query = '';
	callAHAH('GET','terms.php',query,'prod_div','<div id=\'example\' class=\'post\'><h2 class=\'title_\'><span>Loading...</span></h2>'+msg+'</div>');	
}

function show_more_tools()
{	
	
	newwin = window.open("more_tools.php","more_tools","status,titlebar,height=400,width=500,screenX=500,screenY=500,scrollbars",false);
	newwin.focus();
}

function show_tell_friend()
{	
	query = '';
	callAHAH('GET','tell_friends.php',query,'prod_div','<div id=\'example\' class=\'post\'><h2 class=\'title_\'><span>Loading...</span></h2>'+msg+'</div>');	
}

function verify_tell_friend()
{	
	frm = document.tell_friend;
	fullname = frm.fullname.value;
	sender_email = frm.sender_email.value;
	f1 = frm.friend1.value;
	f2 = frm.friend2.value;
	f3 = frm.friend3.value;	
	query = 'fullname='+fullname+'&sender_email='+sender_email+'&friend1='+f1+'&friend2='+f2+'&friend3='+f3+'&flag=1';
	
	callAHAH('POST','tell_friends.php',query,'prod_div','<div id=\'example\' class=\'post\'><h2 class=\'title_\'><span>Loading...</span></h2>'+msg+'</div>');	
}

function show_help()
{	
	callAHAH('GET','help.html','','prod_div','<div id=\'example\' class=\'post\'><h2 class=\'title_\'><span>Loading...</span></h2>'+msg+'</div>');	
}

function show_products(subid,pno)
{	
	query = 'sbid='+subid+'&pno='+pno;
	callAHAH('GET','products.php',query,'prod_div','<div id=\'example\' class=\'post\'><h2 class=\'title_\'><span>Loading...</span></h2>'+msg+'</div>');	
}
function show_user_cinfo(prodid)
{
	
	newwin = window.open("show_user_cinfo.php?pid="+prodid,"user_info","status,titlebar,height=400,width=480,screenX=500,screenY=500",false);
	newwin.focus();
}

function show_reply_box(prodid)
{
	
	newwin = window.open("prod_reply.php?pid="+prodid,"reply_info","status,titlebar,height=400,width=500,screenX=500,screenY=500,scrollbars",false);
	newwin.focus();
}

function show_abuse_box(prodid)
{
	
	newwin = window.open("prod_abuse.php?pid="+prodid,"reply_info","status,titlebar,height=400,width=500,screenX=500,screenY=500,scrollbars",false);
	newwin.focus();
}

///////////////// feed back functions ////////////////
function show_support_form()
{	
	callAHAH('GET','support_form.php','','prod_div','<div id=\'example\' class=\'post\'><h2 class=\'title_\'><span>Loading...</span></h2>'+msg+'</div>');	
}

function verify_support_form()
{
	frm = document.feedback_form;
	
	phone = document.getElementById("phoneno");

	if(frm.fullname.value == '' || frm.inq.value == '-1' || frm.msg.value == '')
	{
		alert("Required fields missing");
		return false;
	}else
	{
		qry = '';
		fullname = frm.fullname.value;
		company = frm.company.value;		
		cno = phone.value;
		email = frm.email.value;
		web = frm.website.value;
		inq = frm.inq.value;
		fmsg = frm.msg.value;
	
		qry += 'fullname="'+fullname+'"&comp="'+company+'"&cno="'+cno+'"&email="'+email+'"';
		qry += '&web="'+web+'"&inq="'+inq+'"&msg="'+fmsg+'"&flag=1';
		//alert(qry);
		
		callAHAH('GET','support_form.php',qry,'prod_div','<div id=\'example\' class=\'post\'><h2 class=\'title_\'><span>Verifying...</span></h2>'+msg+'</div>');

	}
}

///////////////// feed back functions finished ////////////////

///////////////// registration/profile functions started ////////////////
function show_forgot_password()
{	
	callAHAH('GET','forgot_password.php','','prod_div','<div id=\'example\' class=\'post\'><h2 class=\'title_\'><span>Loading...</span></h2>'+msg+'</div>');	
}

function verify_password()
{	
	frm = document.forgotpassword_form;
		
	if(frm.randans.value == '' || frm.email.value == '')
	{
		alert("Required fields missing");
		return false;
	}else
	{
		if(frm.email.value.indexOf(' ') != -1)
		{
			alert("Username can not contain Spaces ' '");
			return false;
		}
		qry = '';		
		randans = frm.randans.value.toLowerCase();
		rno = frm.rno.value;
		email = frm.email.value.toLowerCase();
	
		qry += 'randans='+randans+'&email='+email+'&rno='+rno+'&flag=1';		
		
		callAHAH('POST','forgot_password.php',qry,'prod_div','<div id=\'example\' class=\'post\'><h2 class=\'title_\'><span>Verifying...</span></h2>'+msg+'</div>');

	}
}

function show_users_registration()
{	
	callAHAH('GET','users_registration.php','','prod_div','<div id=\'example\' class=\'post\'><h2 class=\'title_\'><span>Loading...</span></h2>'+msg+'</div>');	
}
function verify_registration()
{
	frm = document.registration_form;
	
	//phone = document.getElementById("phoneno");

	if(frm.fullname.value == '' || frm.city.value == '' || frm.country.value == '' || frm.cell.value == '' || frm.email.value == '')
	{
		alert("Required fields missing");
		return false;
	}else
	{
		qry = '';
		fullname = frm.fullname.value.toUpperCase();
		badd = frm.badd.value.toUpperCase();
		city = frm.city.value.toUpperCase();
		country = frm.country.value.toUpperCase();
		phone = frm.phone.value.toUpperCase();
		cell = frm.cell.value.toUpperCase();
		email = frm.email.value.toLowerCase();
		username = frm.username.value.toLowerCase();
		if(username.indexOf(' ')!= -1)
		{
			alert("Username can not contain Spaces ' '");
			return false;
		}			 
	
		qry += 'fullname='+fullname+'&badd='+badd+'&city='+city+'&country='+country+'';
		qry += '&phone='+phone+'&cell='+cell+'&email='+email+'&username='+username+'&flag=1';
		//alert(qry);
		
		callAHAH('POST','users_registration.php',qry,'prod_div','<div id=\'example\' class=\'post\'><h2 class=\'title_\'><span>Verifying...</span></h2>'+msg+'</div>');

	}
}

function verify_registration2()
{
	qry = '';
	frm = document.registration_form;	
	fullname = frm.fullname.value.toUpperCase();
	badd = frm.badd.value.toUpperCase();
	city = frm.city.value.toUpperCase();
	country = frm.country.value.toUpperCase();
	phone = frm.phone.value.toUpperCase();
	cell = frm.cell.value.toUpperCase();
	email = frm.email.value.toLowerCase();
	username = frm.username.value.toLowerCase();

	frm2 = document.registration_form2;
	vcode = frm2.vcode.value;
	p1 = frm2.password1.value;
	p2 = frm2.password2.value;
	
	if(vcode == '' || p1 == '' || p2 == '')
	{
		alert('Required fields missing.');
		return false;
	}
	if(p1 != p2)
	{
		alert('Password Mismatch!');
		return false;
	}
			 
	
	qry += 'fullname='+fullname+'&badd='+badd+'&city='+city+'&country='+country+'';
	qry += '&phone='+phone+'&cell='+cell+'&email='+email+'&username='+username+'&vcode='+vcode+'&p1='+p1+'&p2='+p2+'&flag=1';
	//alert(qry);
	
	callAHAH('POST','users_registration.php',qry,'prod_div','<div id=\'example\' class=\'post\'><h2 class=\'title_\'><span>Verifying...</span></h2>'+msg+'</div>');	
}

function show_login_form()
{	
	callAHAH('GET','login_form.php','','prod_div','<div id=\'example\' class=\'post\'><h2 class=\'title_\'><span>Loading...</span></h2>'+msg+'</div>');	
}

///////////////////////////////////////
function show_update_profile()
{	
	callAHAH('GET','update_profile.php','','prod_div','<div id=\'example\' class=\'post\'><h2 class=\'title_\'><span>Loading...</span></h2>'+msg+'</div>');	
}

function verify_profile()
{
	frm = document.profile_form;
	
	//phone = document.getElementById("phoneno");

	if(frm.fullname.value == '' || frm.city.value == '' || frm.country.value == '' || frm.cell.value == '' || frm.email.value == '')
	{
		alert("Required fields missing");
		return false;
	}else
	{
		qry = '';
		fullname = frm.fullname.value.toUpperCase();
		badd = frm.badd.value.toUpperCase();
		city = frm.city.value.toUpperCase();
		country = frm.country.value.toUpperCase();
		phone = frm.phone.value.toUpperCase();
		cell = frm.cell.value.toUpperCase();
		email = frm.email.value.toLowerCase();
	
		qry += 'fullname='+fullname+'&badd='+badd+'&city='+city+'&country='+country+'';
		qry += '&phone='+phone+'&cell='+cell+'&email='+email+'&flag=1';
		//alert(qry);
		
		callAHAH('POST','update_profile.php',qry,'prod_div','<div id=\'example\' class=\'post\'><h2 class=\'title_\'><span>Verifying...</span></h2>'+msg+'</div>');

	}
}


/////////////////  registration/profile functions finished ////////////////