function showLoad () {	
	$('#load').slideDown('slow');
}
function showNone(){
	$('#load').slideUp();
}
function toogleslide(id){
     $("#"+id).slideToggle("slow");
}
/*Get requested page*/
function GetPaged(url){
	showLoad();
	var pars = $("#orderform").serialize();
	$('#infobox').html($.ajax({ url:  url, async: false }).responseText);
	showNone();
}
function SubmitFormData(uri,formid,rurl,divid){
	showLoad();
	var pars = $(formid).serialize();
	$.ajax({
		   type: "POST",
		   url: uri,
		   data: pars,
		   success: function(newData){
				
				if(newData.substring(0,7)=='Success'){
					if(divid) {                           /* check for any divids and This Will assign response to some other div Other than the info box messages*/
						$('#infobox').hide();
						$(divid).html(newData.substring(7));
					}
				}else if(newData.substring(0,8)=='CheckOut'){
					window.location = 'checkout.php';
				}else if(newData.substring(0,7)=='Receipt'){
					window.location = 'receipt.php';
				}else if(newData.substring(0,7)=='invalid'){
					document.getElementById('uword').className = 'warningiconbg';
					document.getElementById('pword').className = 'warningiconbg';
				}else if(newData.substring(0,10)=='notsuccess'){
					document.getElementById('h0').className = '';
					document.getElementById('h1').className = '';
					document.getElementById('h2').className = '';
					document.getElementById('h3').className = '';
					document.getElementById('h4').className = '';
					
					if(strstr(newData,'Username') ){
						document.getElementById('h0').className = 'warningiconbg1';
					}
					if(strstr(newData,'first') ){
						document.getElementById('h1').className = 'warningiconbg1';
					}
					if(strstr(newData,'last') ){
						document.getElementById('h2').className = 'warningiconbg1';
					}
					if(strstr(newData,'Email') ){
						document.getElementById('h3').className = 'warningiconbg1';
					}
					if(strstr(newData,'confirmemail') ){
						document.getElementById('h4').className = 'warningiconbg1';
					}
				}else if(newData.substring(0,5)=='valid'){
					window.location = rurl;
				}else{                                             /* This is for displaying any Error messages in Info box   */
					$('#infobox').slideDown("slow");
					$('#infobox').html(newData);
				}
		   }
		});
	showNone();	
}
/**
* Process the ORDER details
*/
function GetOrder(code){
	SubmitFormData('processorder.php', '#orderform', '',  '#alldivs');
}
function ProcessOrder(){
	SubmitFormData('processorder.php?order=process', '#orderform', '',  '#alldivs');
}
function ProcessCheckout(){
	SubmitFormData('checkout_process.php', '#orderform', '',  '');
}
function oshow(value){
//alert($(value).style.display)
		$('#'+value).slideUp();
}
function Quicklogin(rurl){
	SubmitFormData('rpc.php?type=quicklogin', '#quicklogin', rurl,  '');
}
function PopUp(url,formId){
	SubmitFormData(url, formId, '',  '');
}
function strstr (haystack, needle, bool) {
   var pos = 0;
   haystack += '';
    pos = haystack.indexOf( needle );    if (pos == -1) {
        return false;
    } else{
        if (bool){
            return haystack.substr( 0, pos );        } else{
            return haystack.slice( pos );
        }
    }
}
