// JavaScript Document
$(document).ready(function() {
	$('.validaErrorUser').hide();
});
var PATH = 'http://212.95.250.53/~offsp7454';
function submitFormProduct(){
	    errorFlag=0;
		$('.validaErrorUser').hide();
		//var prdType      =  $("select#prdType").val();
		var prdName      =  $("input#prdName").val();
		//var prdCat       =  $("select#prdCat").val();
		var applId       =  $("select#applId").val();
		var indId        =  $("select#industryId").val();
		//alert(indId);
		var applContent         =  CKEDITOR.instances.prdDesc.getData();
		var prdImage     =  $("input#prdImage").val();
		var prdBrouchure =  $("input#prdBrouchure").val();
		
		/*if (prdType == "") {
		
			$("p#prdTypeError").show();
			$("select#prdType").focus();
			//return false;
			errorFlag=1;
		}*/
		if (prdName == "") {
		
			$("p#prdNameError").show();
			$("input#prdName").focus();
			//return false;
			errorFlag=1;
		}
		/*if (prdCat == "") {
		    
			$("p#prdCatError").show();
			$("input#prdCat").focus();
			//return false;
			errorFlag=1;	
		}*/
		if (applId == "") {
		   	$("p#applNameError").show();
			$("input#applName").focus();
			//return false;
			errorFlag=1;
		}
		if (indId == "") {
		   	$("p#indNameError").show();
			$("input#indName").focus();
			//return false;
			errorFlag=1;
		}
		if (applContent == "") {
		   	$("p#appContetError").show();
			//$("input#indName").focus();
			//return false;
			errorFlag=1;
		}
		/*if (prdImage == "") {
		   	$("p#prdImageError").show();
			$("input#prdImage").focus();
			//return false;
			errorFlag=1;
		}
		if (prdBrouchure == "") {
		   	$("p#prdBrouchureError").show();
			$("input#prdBrouchure").focus();
			//return false;
			errorFlag=1;
		}*/
	    if(errorFlag==1){
			return false ;
		}
		//document.frmTest.submit();
		return true;
	}
	function poptastic(url){
		var winl = (screen.width - 450) / 3;
	  	var wint = (screen.height - 450) /3;
		window.open(url,'name','height=450,width=450,top='+wint+',left='+winl+'resizable=1');
	}
	
	 function ShowHideMenu1(visibily){
	
		$("#menuOpen1").animate({"height": "toggle"}, { duration: 500 });
		$("#menu1").animate({"height": "toggle"}, { duration: 500 });
		
	}
	function ShowHideMenu2(visibily){
		$("#menuOpen2").animate({"height": "toggle"}, { duration: 500 });
		$("#menu2").animate({"height": "toggle"}, { duration: 500 });
		
	}
	
	function  deleteProductImage(prdId)
{
	$.ajax({
	url : "ajax.common.php?action=prdImgDel&prdId="+prdId,
	success : function (data) {
	  document.getElementById("imgDelLabel").innerHTML='';
	  document.getElementById("imgViewLabel").innerHTML='';
		
}
});

	
}	
function  loadCategory(typeID)
{
	$.ajax({
	url : "ajax.common.php?action=loadCat&typeID="+typeID,
	success : function (data) {
	  document.getElementById("catDiv").innerHTML=data; 
		
}
});
}
 function loadproductGroups(){
	 industryId    = document.getElementById("industryId").value;
	 //alert(industryId);
	 $.ajax({
	url : PATH+"/modules/intranet/ajax.productGroup.php?industry="+industryId,
	success : function (data) {
	 document.getElementById("productDiv").innerHTML=data;
      
		
	}
	});
 }


 function  loadProducts()
   {
   industryId    = document.getElementById("industry").value;
   applicationId   = document.getElementById("application").value;
  // location .href ='modules/user/ajax.product.php';
	$.ajax({
	url : PATH+"/modules/user/ajax.product.php?industry="+industryId+"&application="+applicationId,
	success : function (data) {
	 document.getElementById("productDiv").innerHTML=data;
      
		
	}
	});
   }
function submitSubscriber()
{
	//remove all the class add the messagebox classes and start fading
	
	//check the username exists or not from ajax
	$.post(PATH+"/modules/user/ajax_subscriber.php",{ subscriber_name:$('#subscriberName').val(),subscriber_email:$('#subscriberEmail').val(),rand:Math.random() } ,function(data)
        {

	  if(data=='yes') //if correct login detail
	  {
		$("#message").html('Subscribed Successfully');
	  }
	  else
	  {
		  $("#message").html('Failed to subscribe');
		  }
       });
       return false;//not to post the  form physically
}
