<!--function call on load event-->
jQuery(document).ready(function(){							
jQuery.blockUI({message: jQuery('#loadpage'),
			css: { 
			top: '300px', 
			left: '', 
			right: '300px', 
            border: 'none', 
            padding: '15px', 
            backgroundColor: '', 
            '-webkit-border-radius': '10px', 
            '-moz-border-radius': '10px', 
            opacity: .5, 
            color: '#fff' 
            } 
});
jQuery("#middle_content").load("include/middlehome.php");
});
<!--function call on load event-->

function load_after_click(str){

var page=str+".php";
jQuery.blockUI({message: jQuery('#loadpage'),
			css: { 
			top: '300px', 
			left: '', 
			right: '300px', 
            border: 'none', 
            padding: '15px', 
            backgroundColor: '', 
            '-webkit-border-radius': '10px', 
            '-moz-border-radius': '10px', 
            opacity: .5, 
            color: '#fff' 
            } 
	}); 	
jQuery("a").removeClass('hover');
jQuery("a").removeClass('hover1');
jQuery("a").removeClass('hover2');
jQuery("a").removeClass('hover3');
if(str=="middlehome")
{	
jQuery('#'+str).addClass('hover');	
}
if(str=="about_us")
{
jQuery('#'+str).addClass('hover1');	
}
if(str=="subscription")
{
jQuery('#'+str).addClass('hover2');	
}
if(str=="contact")
{
jQuery('#'+str).addClass('hover3');	
}
jQuery("#middle_content").load("include/"+page);
}

function view_product(id)
{
	jQuery("#middle_content").load("include/product.php",{prod_id:id});
}

function product_info(str,str1)
{
	jQuery("#middle_content").load("include/product_info.php",{prod_id:str,id:str1});
}

function cont_shopping(str)
{
	jQuery("#middle_content").load("include/product.php",{prod_id:str});
}


function register_user(str)
{
	var title=document.getElementById('title').value;
	var fname=document.getElementById('fname').value;
	var lname=document.getElementById('lname').value;
	var email=document.getElementById('email').value;
	var phone=document.getElementById('phone').value;
	var cellphone=document.getElementById('cellphone').value;
	var address=document.getElementById('address').value;
	var city=document.getElementById('city').value;
	var state=document.getElementById('state').value;
	var Country=document.getElementById('Country').value;
	var zipcode=document.getElementById('zipcode').value;
	var password=document.getElementById('pass').value;
	var confirmpass=document.getElementById('confirmpass').value;
	if(password !=confirmpass)
	{		
		document.getElementById('spanerr').style.display='block';
		return;
	}
		var valid = new Validation('frm', {immediate:true,onSubmit:false});
		if(valid.validate())
		{
			
		jQuery.post("include/save_user.php",{title:title,fname:fname,lname:lname,email:email,phone:phone,cellphone:cellphone,address:address,city:city,state:state,Country:Country,zipcode:zipcode,password:password},function(data)
		{
		if(data.check==0)
		{	
		document.getElementById('spanerrmail').style.display='block';
		return;		
		}
		else
		{
		
		jQuery("#middle_content").load("include/login.php",{itemid:str});
		}
		},"json"
		);	
		}
		
}

function user_register(str)
{
	jQuery("#middle_content").load("include/registeration.php",{itemid:str});
}

function add_cart(str)
{
	
	jQuery.post("include/add_cart.php",{itemid:str},function(data)
		{
		
		if(data.check==0)
		{
		jQuery("#middle_content").load("include/login.php",{itemid:str});
		}
		else
		{
		jQuery("#middle_content").load("include/wish_list.php");	
		}
		},"json"
		);	
	
}


function OnKeyPress(event,str)
{
	if (event.keyCode == 13 )
	{
		alert('hi');
	}
}


function login(str)
{
	var email=document.getElementById('email').value;
	var password=document.getElementById('pass').value;
	var valid = new Validation('frm', {immediate:true,onSubmit:false});
	if(valid.validate())
	{			
		jQuery.post("include/chklogin.php",{email:email,password:password},function(data)
		{
			
			if(data.check==1)
			{
			add_cart(str);
			}
			else
			{
				document.getElementById('spanerr').style.display='block';
		        return;

			}
		},"json"
		);	
	}
}

function delete_item(str)
{
	
	jQuery.post("include/manage_cart.php",{id:1,itemid:str},function(data)
		{
		
		if(data.check==1)
		{
		jQuery("#middle_content").load("include/wish_list.php");
		}
		},"json"
		);
}

function update_qty(str,str1)
{
	var qty=document.getElementById(str).value;
	var reg_isInteger = /^\d+$/;
	if(reg_isInteger.test(qty))
	{
     jQuery.post("include/manage_cart.php",{id:2,itemid:str,qty:qty,cost:str1},function(data){
		if(data.check==1)
		{
			jQuery("#middle_content").load("include/wish_list.php");
		}},"json"
		);
	}
	else
	{
		return;
	}
	//var qty=document.getElementById(str).value;
	//	var valid = new Validation('frm', {immediate:true,onSubmit:false});
	//	if(valid.validate())
	//	{
	//	jQuery.post("include/manage_cart.php",{id:2,itemid:str,qty:qty,cost:str1},function(data)
	//		{
	//		
	//		if(data.check==1)
	//		{
	//		jQuery("#middle_content").load("include/wish_list.php");
	//		}
	//		},"json"
	//		);
	//	}
}

function checkout()
{
	jQuery("#middle_content").load("include/checkout.php");
}

function confirm_order()
{   

    var deliveryaddress=document.getElementById('delivery_address').value;
	jQuery("#middle_content").load("include/confirm_order.php",{deliveryaddress:deliveryaddress});
}

function save_order(str)
{
		jQuery.post("include/save_order.php",{deliveryaddress:str},function(data)
		{
		if(data.check==1)
		{   order_id=data.order_id;
		    amount=data.amount;
		    quantity=data.quantity;
			jQuery("#payment").hide();
			jQuery("#process").show();
			jQuery("#middle_content").load("include/transfer_payment.php",{order_id:order_id,amount:amount,quantity:quantity});
		}
		},"json"
		);
	
}

function contact_us(str)
{
    
   	var fname=document.getElementById('fname').value;
	var email=document.getElementById('email').value;
	var code=document.getElementById('code').value;
	var phone=document.getElementById('phone').value;
	var address=document.getElementById('address').value;
	var city=document.getElementById('city').value;
	var state=document.getElementById('state').value;
	var Country=document.getElementById('Country').value;
	var zipcode=document.getElementById('zipcode').value;
	var msg=document.getElementById('msg').value;
	var hearaboutus=document.getElementById('hearaboutus').value;
	var valid = new Validation('frmcontact', {immediate:true,onSubmit:false});
	if(valid.validate())
	{			
		if(code != str)
		{
		document.getElementById('spanerrcode').style.display='block';
		return;
		}
		else
		{
		jQuery.blockUI({ 
            message: jQuery('#messageshow'), 
            fadeIn: 700, 
            fadeOut: 700, 
            showOverlay: false, 
            centerY: false, 
            css: { 
                width: '500px', 
                top: '200px', 
                left: '30%', 
                right: '400px', 
                border: 'none', 
                padding: '5px', 
                backgroundColor: '#000', 
                '-webkit-border-radius': '10px', 
                '-moz-border-radius': '10px', 
                opacity: .6,
			    color: '#fff' 
            } 
        }); 
		
		jQuery.post("include/save_contact.php",{name:name,email:email,phone:phone,address:address,city:city,state:state,Country:        Country,zipcode:zipcode,msg:msg,hearaboutus:hearaboutus},function(data)
		{
				if(data.check==1)
				{
				setTimeout(function(){jQuery.unblockUI();return false; },5000);
				jQuery("#middle_content").load("include/contactre.php");
				}
		},"json"
		);	
		}
	}
	
}

function submitDoc(formName) { 
 // var obj;
 document.gateway.action="https://www.paypal.com/cgi-bin/webscr";
 document.gateway.submit();
	//if (obj=findObj(formName)!=null) 
//	{
//		findObj(formName).submit(); 
//	}
//	else 
//	{
//		alert('The form you are attempting to submit called \'' + formName + '\' couldn\'t be found. Please make sure the submitDoc function has the correct id and name.');
//	}

}
