
	
window.itemMainArr = new Array();
window.docWidth= 0;
actionControllerPath = "modules/utility.php" ;
window.itemInfoCollection = new Array();
window.itemsCollection = new Array();
window.currentItemCode = "" ;
//$e('msgAlertDiv').style.left= 1500; //for div used to show alert messages or and info to user in animated view 
//---------------------------------------------------------------------------------------
if(navigator.appName == "Microsoft Internet Explorer"){
	window.firefox = false;
}else{
	window.firefox = true;
}
window.firefox = false;
//Coder: Vijaita Khandelwal
//Purpose: function to get any HTML element object by its ID
function $e(elem){
	if(elem)return document.getElementById(elem);
}

//This function  encodes  and returns string which wil be decoded and used   in PHP  . 
	function URLEncode(plaintext){
		// The Javascript escape and unescape functions do not correspond
		// with what browsers actually do...
		var SAFECHARS = "0123456789" +					// Numeric
						"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
						"abcdefghijklmnopqrstuvwxyz" +
						"-_.!~*'()";					// RFC2396 Mark characters
		var HEX = "0123456789ABCDEF";
		
		var encoded = "";
		for (var i = 0; i < plaintext.length; i++ ) {
			var ch = plaintext.charAt(i);
		    if (ch == " ") {
			    encoded += "+";				// x-www-urlencoded, rather than %20
			} else if (SAFECHARS.indexOf(ch) != -1) {
			    encoded += ch;
			} else {
			    var charCode = ch.charCodeAt(0);
				if (charCode > 255) {
				    alert( "Unicode Character '" 
	                        + ch 
	                        + "' cannot be encoded using standard URL encoding.\n" +
					          "(URL encoding only supports 8-bit characters.)\n" +
							  "A space (+) will be substituted." );
					encoded += "+";
				} else {
					encoded += "%";
					encoded += HEX.charAt((charCode >> 4) & 0xF);
					encoded += HEX.charAt(charCode & 0xF);
				}
			}
		} // for		
			return encoded;
	};
	
//This function  decodes  and returns string which was encoded  in PHP and to be used in JavaScript . 
	function URLDecode(encoded){
	   // Replace + with ' '
	   // Replace %xx with equivalent character
	   // Put [ERROR] in output if %xx is invalid.
	   var HEXCHARS = "0123456789ABCDEFabcdef";    
	   var plaintext = "";
	   var i = 0;
	   while (i < encoded.length) {
	       var ch = encoded.charAt(i);
		   if (ch == "+") {
		       plaintext += " ";
			   i++;
		   } else if (ch == "%") {
				if (i < (encoded.length-2) 
						&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 
						&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
					plaintext += unescape( encoded.substr(i,3) );
					i += 3;
				} else {
					alert( 'Bad escape combination near ...' + encoded.substr(i) );
					plaintext += "%[ERROR]";
					i++;
				}
			} else {
			   plaintext += ch;
			   i++;
			}
		} // while
	   return  plaintext;   
	};
	
//Coder: Vijaita Khandelwal
//Purpose: This function is to set cookie for user.	
function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure ){
  var cookie_string = name + "=" + escape ( value );

  if ( exp_y )
  {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }

  if ( path )
        cookie_string += "; path=" + escape ( path );

  if ( domain )
        cookie_string += "; domain=" + escape ( domain );
  
  if ( secure )
        cookie_string += "; secure";
  
  //alert(cookie_string);
  document.cookie = cookie_string;
 
}

//Coder: Vijaita Khandelwal
//Purpose: This function is to destroy current sesion by deleting the cookies set earlier.
function delete_cookie ( cookie_name ){
  var cookie_date = new Date( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}

function get_cookie ( cookie_name ){
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}

//----------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------

//Purpose : To remove spaces from starting and end of any string .
function trimString(sInString) {
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
}

//Coder: Vijaita Khandelwal
//Purpose: To remove spaces from starting and end of any string .
function trim(s){
	if((s==null)||(typeof(s)!='string')||!s.length)return'';return s.replace(/^\s+/,'').replace(/\s+$/,'')}

	
//Coder: Vijaita Khandelwal
//Purpose: Function to open user registration form for any new user .	
function openUserRegistrationForm()
{
	var str = "<img onmouseout=\"this.src='imgs/close_d.gif'\"; onmouseover=\"this.src='imgs/close_h.gif'\"; onclick=\"$e('log_form').style.display='none';\" src=\"imgs/close_d.gif\" style=\"float:right;margin-top:-13px;margin-right:2px;\"></img>"+
	
			//"<label> We are in private closed beta !</label><br>"+
			//"<label> But ,you can register for beta testing account </label><br>"+
			"<label> Please provide correct information as your account activation link will be sent on given email id . </label><br>"+
			"Your  FirstName:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+
			"<input type=\"text\" id=\"firstName\" class=\"joinForm\" size=\"25\" maxlength=\"15\" value=\"\" class=\"inp\"  ></input>"+
			"<br>"+
			"Your Screen Name:&nbsp;&nbsp;"+
			"<input type=\"text\" id=\"screenName\" class=\"joinForm\" size=\"25\" maxlength=\"40\" value=\"\" class=\"inp\"  ></input>"+
			"<br>"+
			"Your E-Mail:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+
			"<input type=\"text\" id=\"loginName\" class=\"joinForm\" size=\"25\" value=\"\" class=\"inp\" ></input>"+
			"<br>"+
			"Password:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+
			"<input type=\"password\" id=\"userPassword\" class=\"joinForm\" size=\"25\" maxlength=\"20\" value=\"\" class=\"inp\" ></input>"+
			"<br>"+
			"Confirm Password:&nbsp;&nbsp;<input type=\"password\" id=\"cPassword\" maxlength=\"20\" class=\"joinForm\" size=\"25\" value=\"\" class=\"inp\" ></input>"+
			"<br><br>"+
			"<label id='reg_errorMsg' style='padding:2px;background-color:orange;color:white;display:none;' ></label>"+	
			"<input type='button' onclick=\"saveUserLoginInfo('firstName','screenName','loginName','userPassword','cPassword','tempLogin');\" value=\"Register Me\" ></input>" ;
			
	$e('log_form').innerHTML = str ;	
	$('.rou').css('background-image',"url('')");	
	$('.rou').css('background-image',"url('imgs/strip.jpg')");	
	$('.rou').css('background-repeat',"repeat");
	$('.rou').css('font-size','14px');
	$('.rou').css('height','250px');
	$('.rou').css('color','#000000');
	$('.rou').css('font-family','tahoma');
	//$('.rou').css('font-size','.8em');
	$e('log_form').style.display='block';
}	

//Coder: Vijaita Khandelwal
//Purpose: Function to open user login form for any existing user . 
function openUserLoginForm(){
	var str = "<img onmouseout=\"this.src='imgs/close_d.gif'\"; onmouseover=\"this.src='imgs/close_h.gif'\"; onclick=\"$e('log_form').style.display='none';\" src=\"imgs/close_d.gif\" style=\"float:right;margin-top:-13px;margin-right:10px;\"></img>"+
		"<div style=\"margin-top:40px;width:95%;height:75%;left:0px;\" >"+
				"<label style='margin-top:80px;'>E-Mail ID:</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"text\" id=\"uname\" class=\"loginForm\" size=\"25\" value=\"gridbots@gmail.com\" class=\"inp\" onChange=\"$e('wpass').style.display = 'none';\"></input>"+
			"<br>"+
			"<label style='margin-top:40px;'>password:</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input $e('wpass').style.display = 'none' type=\"password\" id=\"uPassword\" class=\"loginForm\" size=\"25\" value=\"gridbots\" class=\"inp\"></input>"+
			"<br><br>"+
			"<label id='wpass' style='background-color:red;color:white;display:none;'>Incorrect Login Info</label>"+
			"<input style=\"margin-left:230px;\" type=\"button\" value=\"Login\" class=\"formButton\" "+
			"onclick=\"checkUserLogin($e('uname').value,$e('uPassword').value);\" >"+
		"</div>" ;
		
	$('.rou').css('background-image',"url('')");
	$('.rou').css('background-image',"url('imgs/login_check_btn.jpg')");	
	if(window.firefox) $('.rou').css('background-repeat',"no-repeat'");	
	//$('.rou').css('backgroundRepeat',"no-repeat'");	
	$('.rou').css('height','160px');
	$('.rou').css('color','#ffffff');
	$('.rou').css('font-family','tahoma');
	$('.rou').css('font-size','1em');
	$e('log_form').innerHTML = str ;	
	$e('log_form').style.display='block';
}
	

//Coder: Vijaita Khandelwal
//Purpose: This function is to save user registration info.
function saveUserLoginInfo(firstName,screenName,loginName,userPassword,confirmPassword,callType){
		//alert('fdsfd');
		// validating all fields 
		dataValidation(firstName,'is_alphanumeric','1');
		dataValidation(screenName,'is_alphanumeric','1');
		echeck(loginName,'');
		dataValidation(userPassword,'is_alphanumeric','1');
		if(!flagForInvalidFormVal){
			flagForInvalidFormVal = true ;
			$e('reg_errorMsg').style.display = 'block'; 
			$('#reg_errorMsg').html("Please give correct values for red coloured inputs.");
			//alert("Plz give correct values for red coloured inputs.");
			return ;
		}
		var fName = URLEncode($e(firstName).value) ;
		var sName = URLEncode($e(screenName).value) ;
		var lName = URLEncode($e(loginName).value) ;
		var pswd = URLEncode($e(userPassword).value) ;
		var cpswd = URLEncode($e(confirmPassword).value) ;
		var urlParams='';
		if(fName == '' || sName == '' || lName == '' || pswd == '' || cpswd == ''){
			$e('reg_errorMsg').style.display = 'block'; 
			$('#reg_errorMsg').html("Fill the complete form");
			return;
		}
		if(pswd.toLowerCase() != cpswd.toLowerCase()){
			$e('reg_errorMsg').style.display = 'block'; 
			$('#reg_errorMsg').html(" Password does not matches with comfirm password");
			pswd = "";
			cpswd = "" ;
			return ;
		}
		if(pswd.length < 6){
			$e('reg_errorMsg').style.display = 'block'; 
			$('#reg_errorMsg').html("password length should be more than 6");
			return ;
		}
		//When v r giving activation link to the registring person	
		if(callType == 'tempLogin'){
			urlParams='&loginName='+lName+'&userPassword='+pswd+'&confirmPassword='+cpswd+'&screenName='+sName+
						'&firstName='+fName+'&callType=tempLogin' ;
		}
		//Original registration 
		else{
			urlParams='&loginName='+lName+'&userPassword='+pswd+'&confirmPassword='+cpswd+'&screenName='+sName+
						'&firstName='+fName+'&callType=' ;
		}				
		//alert(urlParams);
		//return ;
		myconn = new ajaxprocess();		
		var resultFunction = function(resultObject){ 
			var response_prev = resultObject.responseText;	
			var response = returnHTML(response_prev);	
			//alert(response);
			//if(window.firefox )console.log(response);
			$e('reg_errorMsg').style.display = 'block'; 
			$('#reg_errorMsg').css('background-color','orange');
			$('#reg_errorMsg').css('color','black');
			
			switch(trim(response)){
				case '0' :	$('#reg_errorMsg').html("Registration failed , check back later");	
							break ;
				case '1' :		
						//$('#reg_errorMsg').html = "Registration successful !<br>Activation link has been sent to your E Mail address specified above.<br>Check your mail and click the activation link.If you dont find mail in your inbox check your junk folder too ! ";
						$('#reg_errorMsg').css('background-color','#E3F4FC');
						$('#reg_errorMsg').css('color','green');
						$('#reg_errorMsg').html("Thanks for registering with us, check your mailbox.");
						//$e('regis').style.display = 'none' ;
						$e(firstName).value = '' ;
						$e(screenName).value = '' ;
						$e(loginName).value ='' ;
						$e(userPassword).value='' ;
						$e(confirmPassword).value='' ;
						//if($e('log')) $e('log').style.display = 'block' ;
						break ;
				case '2' :return;
						$('#reg_errorMsg').html("Both password strings are not same ");
						break ;	
				case '3' :		
						$('#reg_errorMsg').html("password length should be more than 6 characters");
						break ;
				case '4' :
						
						$('#reg_errorMsg').html("User with this email id has already registered, try a different Email ID.");
						break ;
			}
			
			
			
		};
		myconn.ajaxclass('get',actionControllerPath+'?opCode=saveUserRegInfo'+urlParams,"null",resultFunction);
			
	}
	
//Coder: Vijaita Khandelwal
//Purpose: Function to set userId in cookies after successfull login .	
function setUserIdINCookie(name,id,orderCode){
	
	set_cookie ( "username", name ,"","/","www.edubotix.in");
	set_cookie ( "orderId", orderCode ,"","/","www.edubotix.in");
	set_cookie ( "userId", id ,"","/","www.edubotix.in");
	set_cookie ( "itemCount", 0 ,"","/","www.edubotix.in");
	set_cookie ( "newUser", 0 ,"","/","www.edubotix.in");
}

//PURPOSE : to set virtual user details in case user has not logged in  
function setUserDetailsBeforeLogin(){
	
	if( get_cookie('newUser') == 1 || get_cookie('newUser') == null){
		//showDebug("Sorry ! you need to login .");
		//alert("Sorry ! you need to login .");
		set_cookie ( "userId", 9999 ,"","/","www.edubotix.in");
		//set_cookie ( "orderId", 9999 ,"","/","www.edubotix.in");
		set_cookie ( "newUser", 1 ,"","/","www.edubotix.in");
		
		return ;
	}
	
}

//Coder: Vijaita Khandelwal
//Purpose: Function to show changes according to the current session for current user  and also keep a check whether session is continue or not.
function maintainSession(){
	
	//alert(get_cookie ('userId'));
	//if(get_cookie ('userId') == null || get_cookie ('userId') =="" || get_cookie ('userId') == undefined){
	if(get_cookie ('newUser') == 1  || get_cookie ('newUser') == null ){
		//alert('login');
		$e('login_Link').style.display = 'block';
		$e('newUser_Link').style.display = 'block';
		$e('link_seperator').style.display = 'block';
		
		$e('logout_Link').style.display = 'none';
		set_cookie ( "newUser", 1 ,"","/","www.edubotix.in");
	}
	else{
		//alert('logOut');
		$e('login_Link').style.display = 'none';
		$e('newUser_Link').style.display = 'none';
		$e('link_seperator').style.display = 'none';
		$e('logout_Link').style.display = 'block';
	}
	
	var currItemCnt = get_cookie ('itemCount');
	if(currItemCnt > 0){
		//alert('show cart');
		//$('#login_CartImgDiv').css('background-image', "url('imgs/Homepage_fullCart.gif')");
		$e('showCartBtnImg').style.display = 'block';
		$e('emptyCartBtnImg').style.display = 'none';
		$e('fullCartBtnImg').style.display = 'block';
		
	}
	else{
		//alert('hhhhhhhhhhhhhhh');
		//$('#login_CartImgDiv').css('background-image', "url('imgs/Homepage-emptyCart.gif')");
		$e('showCartBtnImg').style.display = 'none';
		$e('emptyCartBtnImg').style.display = 'block';
		$e('fullCartBtnImg').style.display = 'none';
	}
}

//Coder: Vijaita Khandelwal
//Purpose: Function to destroy current session  .	
function destroySession(){
	delete_cookie ( 'username' );
	delete_cookie ( 'orderId' );
	delete_cookie ( 'userId' );
	delete_cookie ( 'itemCount' );
	//location.href("index.php");
	showDebug("You have logged Out successfully.");
	setUserDetailsBeforeLogin();
	maintainSession();
}	

//Coder: Vijaita Khandelwal
//Purpose: Function to add any item selected by user to his cart.
function addItemToCart(itemCode,callType,itemQTY){
		
		set_cookie ( "checkCookieStatus", 1 ,"","/","www.edubotix.in");
		if(get_cookie ('checkCookieStatus') != 1){
			var str = "Your cookies are disabled . Please enable them to continue shopping " ;
			alert(str);
			return ;
		}
		var i=0;
		var item=""  ;
		var	qty=0 ; 
		var	cost=0 ;
		var newItemCnt =0;	
		var currItemCnt =0;		
		//alert(itemCode);
		if(callType == 'direct') {
			i=0;
			qty = itemQTY ; //on adding from product quantity is specified by user 
			cost= window.itemInfoCollection[i].price ;
					
		}
		else{
			for(i=0 ; i < window.itemMainArr.length ; i++){
				if(itemCode == window.itemMainArr[i].code)break ;
			}
			item = window.itemMainArr[i].code ;
			qty = 1 ; //on adding item directly from main product menu quantity will be bydefault 1 .
			cost= window.itemMainArr[i].price ;
		}
		var userId=0 ; var orderCode = '' ;
		var flagForNewUser = get_cookie ('newUser') ;
		//-------------If either user is not registered with us or not signed in----------------------------------
		//alert(get_cookie ('newUser'));
		//alert(get_cookie ('orderId'));
		if(get_cookie ('newUser') == 1 && (get_cookie ('orderId')=='' || get_cookie ('orderId')==null) ){ 
			//alert('1');
			orderCode = '' ;
			set_cookie ( "orderId", "" ,"","/","www.edubotix.in");
		}
		else{
			//alert('22');
			orderCode = get_cookie ('orderId') ;
		}	
		userId = get_cookie ('userId') ;	
 		//-----------------------------------------------------------------------
		var str = '&itemCode='+itemCode+'&qty='+qty+'&cost='+cost+'&userId='+userId+'&orderCode='+orderCode+'&isNewUser='+flagForNewUser ;

		//alert(str);
		//return ;
		myconn = new ajaxprocess();				
		var resultFunction = function(resultObject) 
		{ 
			var response_prev = resultObject.responseText;	
			var response = returnHTML(response_prev);	
			//alert(response);
			//if(window.firefox )console.log(response);
			response  = trim(response);
			if(get_cookie ('newUser') == 1){ 
				if(trim(response) == ''){
					showDebug(" Sorry ! Please try again .");
				}else{
					if(get_cookie ('orderId') == ''){ 
						set_cookie( "orderId", trim(response) ,"","/","www.edubotix.in");
					}
					//MAINTAINING NUMBER OF ITEMS SELECTED BY USER DURING ONE SESSION
					currItemCnt = get_cookie ('itemCount');
					newItemCnt = currItemCnt + qty ;
					set_cookie( "itemCount", newItemCnt ,"","/","www.edubotix.in");
					//set_cookie ( "itemCount", newItemCnt ,"","/","http://localhost/edubotix");
					maintainSession();
					showDebug(" Item added successfully to your cart .");
				}
			}
			else{		
				if(response == 1){
					//MAINTAINING NUMBER OF ITEMS SELECTED BY USER DURING ONE SESSION
					currItemCnt = get_cookie ('itemCount');
					newItemCnt = currItemCnt + qty ;
					set_cookie( "itemCount", newItemCnt ,"","/","www.edubotix.in");
					//set_cookie ( "itemCount", newItemCnt ,"","/","http://localhost/edubotix");
					maintainSession();
					showDebug(" Item added successfully to your cart .");
				}else{
					showDebug(" Sorry ! Please try again .");
				}
			}
			
			//-----------------------------------------------------------	
		};
		myconn.ajaxclass('get',actionControllerPath+'?opCode=addItemToCart'+str
					,"null",resultFunction); 	
		return;
	
}

//Coder: Vijaita Khandelwal
//Purpose: Function to check login information given by user via sending request to server.
function checkUserLogin(userName,password){
		
		var loginName  = userName ;
		var pswd  = password ;
		//var loginName  = 'gridbots' ;
		//var pswd  = 'gridbots' ;
		
		myconn = new ajaxprocess();				
		var resultFunction = function(resultObject) 
		{ 
			var response_prev = resultObject.responseText;	
			var response = returnHTML(response_prev);	
			//alert(response);
			//if(window.firefox )console.log(response);
			response  = trim(response);
			if(response == 0 || response == '0')
			{
				//if(window.firefox)console.log("login unsuccessfull");
				//showDebug("Sorry ! login failed , please try again .");
				$e('wpass').style.backgroundColor= 'red' ;
				$('#wpass').html('Incorrect Login Info' );
				$e('wpass').style.display = 'block' ;					
			}
			else{
				showDebug("You have logged In successfully.");
				$e('log_form').style.display = 'none';
				responseArr = response.split(',');
				setUserIdINCookie(loginName,responseArr[0],responseArr[1]);	
				maintainSession();
			}		
			
		};
		myconn.ajaxclass('get',actionControllerPath+'?opCode=checkUserLogin&loginName='+
					loginName+'&pswd='+pswd ,"null",resultFunction); 	
		return;
	
}

//Coder: Vijaita Khandelwal
//Purpose: Function to show complete information regarding any product via re-drecting to the product page.
function showProduct(itemCode){
	var i=0;
	//alert(itemCode);
	for(i=0; i < window.itemMainArr.length ; i++){
		if(window.itemMainArr[i].code == itemCode){
			break ;
		}
		
	}
	//alert(i);
	window.currentItemCode = itemCode ;
	var filePath = "product.php?item="+itemCode ;
	//alert(filePath);
	location.href = filePath;
	
	
}
//PRODUCT : Function to show product details fetched from DB in opened Product Page
function showItemDetailsViaHTML(itemCode){
	//alert(itemCode);
	str = '&itemCode='+URLEncode(itemCode) ;
	myconn = new ajaxprocess();				
	var resultFunction = function(resultObject) 
	{ 
		var response_prev = resultObject.responseText;	
		var response = returnHTML(response_prev);	
		//alert(response);
		response  = trim(response);
		if(window.firefox )console.log(response);
		
		$e('product_desc').innerHTML = URLDecode(window.itemInfoCollection[0].desc) ;
		$e('product_desc').innerHTML = $e('product_desc').innerHTML + URLDecode(window.itemInfoCollection[0].overview) ;
		$e('product_desc').innerHTML = $e('product_desc').innerHTML + URLDecode(window.itemInfoCollection[0].included) ;
		$e('product_desc').innerHTML = $e('product_desc').innerHTML + URLDecode(window.itemInfoCollection[0].technicalSpec) ;
		
		/* $e('product_overview').innerHTML =  URLDecode(window.itemInfoCollection[0].overview);
		$e('product_included').innerHTML =  URLDecode(window.itemInfoCollection[0].included);
		$e('product_technicalSpec').innerHTML =  URLDecode(window.itemInfoCollection[0].technicalSpec); */
		$e('item_code').innerHTML = URLDecode(window.itemInfoCollection[0].code);
		$e('item_price').innerHTML = 'INR '+URLDecode(window.itemInfoCollection[0].price);
		
		//alert(URLDecode(window.itemInfoCollection[0].thumbPath));
		var thumbnailPath = URLDecode(window.itemInfoCollection[0].thumbPath) ;
		var fullViewPath = URLDecode(window.itemInfoCollection[0].fullViewPath) ;
		document.getElementById('img_thumb_1').src =  thumbnailPath + "_1.jpg" ;
		
		document.getElementById('img_thumb_2').src = thumbnailPath +"_2.jpg" ;
		document.getElementById('img_thumb_3').src = thumbnailPath +"_3.jpg" ;
		document.getElementById('fullViewImg').src = fullViewPath +"_1.jpg" ;
		
		
		return;
		
	};
	myconn.ajaxclass('get',actionControllerPath+'?opCode=showItemDetails'+str ,"null",resultFunction); 	
	return ;
}

function addToItemInfoCollection(id,name,code,price,thumb_path,fullViewPath,desc,overview,included,technicalSpec){
	this.id = id ;
	this.name = name ;
	this.code = code ;
	this.price = price ;
	this.thumbPath = thumb_path ;
	this.fullViewPath = fullViewPath ;
	this.desc = desc ;
	this.overview = overview ;
	this.included = included ;
	this.technicalSpec = technicalSpec ;
	//this.status = status ;
}
	

//Coder: Vijaita Khandelwal
//Purpose: Function to add item directly from the product info page.
function addItemToCartFromProductPage(){
	
	var code = window.currentItemCode ;
	var itemQTY = $e('prod_qty').value ;
	addItemToCart(code,'direct',itemQTY);
	
}

//Coder: Vijaita Khandelwal
//Purpose: Function to add item to global collection of item object ARray.
function addToItemCollection(name,price,url,code){
		this.url = url;
		this.price = price ;
		this.name = name ;
		this.code = code ;
	}
	
//Coder: Vijaita Khandelwal
//Purpose: Function to create cart collection as per user selection .	
function addItemToCartCollection(item,qty,cost){
		this.item = item;
		this.qty = qty ;
		this.amount = cost * qty;
		this.cost = cost ;
	}
	
//Coder: Vijaita Khandelwal
//Purpose: Function to show alert messages to user .	
function showDebug(msg){
		
		document.getElementById('msgAlertDiv').innerHTML = msg;			window.docWidth = $(document).width();	
		
		if(parseInt($('#msgAlertDiv').css('left')) >= parseInt(window.docWidth)){			
			$('#msgAlertDiv').animate({left:debug_init,opacity:'show'},750);			
			$('#msgAlertDiv').animate({left:1500,opacity:'hide'},4000);							
			
		}
	}
	
//Coder : Vijaita Khandelwal	
//PURPOSE : Function to re-direct to myCart.html to show user's current session cart items .	
function showMyCart(){
	/*
	if(!get_cookie('userId')){
		
		showDebug("Sorry ! you need to login .");
		return ;
	}
	*/
	location.href = "myCart.html" ;
	
}	

function showEventInfo(){
	location.href ='event.html' ;
}

//PURPOSE : function to submit final order in the database
function submitOrder(totalAmount){
	/*
	if(!get_cookie('userId')){
		
		showDebug("Sorry ! you need to login .");
		return ;
	}
	else{
	*/
		openFormToGetShippingAddress();
	//}
	return ;
}

function openFormToGetShippingAddress(){
	
	if(get_cookie ('newUser') == 1){
		
		var str = "<table cellspacing=1 cellpadding=0 >"+
						"<tr>"+
							"<td colspan=2 >"+
								"<img onmouseout=\"this.src='imgs/close_d.gif'\"; onmouseover=\"this.src='imgs/close_h.gif'\"; onclick=\"$e('order_form').style.display='none';\" src=\"imgs/close_d.gif\" style=\"float:right;margin-top:-13px;margin-right:111px;\"></img>"+
							"</td>"+
						"</tr>"+
						"<tr>"+
							"<td width='40%' >"+
								"<h4>Name</h4>"+
							"</td>"+
							"<td width='60%'>"+
								"<input type='textbox' value='' size='25' maxlength='50' id='name' ></input>"+
							"</td>"+
						"</tr>"+
						"<tr>"+
							"<td width='40%' >"+
								"<h4>Contact No.</h4>"+
							"</td>"+
							"<td width='60%'>"+
								"<input type='textbox' value='' size='25' maxlength='50' id='phone' ></input>"+
							"</td>"+
						"</tr>"+
						"<tr>"+
							"<td width='40%' >"+
								"<h4>Email Id</h4>"+
							"</td>"+
							"<td width='60%'>"+
								"<input type='textbox' value='' size='25' maxlength='50' id='mail' ></input>"+
							"</td>"+
						"</tr>"+
						"<tr>"+
							"<td width='40%' >"+
								"<h4>Shipping Address</h4>"+
							"</td>"+
							"<td width='60%'>"+
								"<textarea id='shipping_adr' rows='4' cols='25'></textarea>"+
							"</td>"+
						"</tr>"+
						"<tr>"+
							"<td width='40%' >"+
								
							"</td>"+
							"<td width='60%'>"+
								"<input type='button' onClick=\"sendOrder('shipping_adr','name','phone','mail');return false;\" value='Submit'></input>"+
							"</td>"+
						"</tr>"+
					"<table>" ;
				
	
	}
	else{
		
		var str = "<img onmouseout=\"this.src='imgs/close_d.gif'\"; onmouseover=\"this.src='imgs/close_h.gif'\"; onclick=\"$e('order_form').style.display='none';\" src=\"imgs/close_d.gif\" style=\"float:right;margin-top:-13px;margin-right:111px;\"></img>"+
				"<h4>Your Shipping Address</h4>"+
				"<textarea id='shipping_adr' rows='4' cols='25'></textarea>"+
				"<br><input type='button' onClick=\"sendOrder('shipping_adr');return false;\" value='Submit'></input>";
	
	}
	$('#order_form').html(str);
	$e('order_form').style.display = 'block';
	
}

function sendOrder(shippingAdrs,name,phone,mail){
	if(!get_cookie('userId')){
		showDebug("Sorry ! you need to login .");
		return ;
	}
	else{
		userId = get_cookie ('userId');
		orderCode = get_cookie ('orderId');
		var shippingStr = $e(shippingAdrs).value ;
		var userName = '' ;
		var phoneNo = '' ;
		var mailId = '' ;
		if(get_cookie('newUser') == 1){
			userName = trim($e(name).value) ;
			phoneNo = trim($e(phone).value) ;
			mailId = trim($e(mail).value) ;
			
			if(userName == '' || phoneNo == '' || mailId ==''){
				showDebug("Please fill the complete contact information .");	
			}
		}
		if(get_cookie('itemCount') > 0){
			str = '&userId='+userId+'&orderCode='+orderCode+'&shippingAdrs='+shippingStr+'&name='+userName+'&phone='+phoneNo+'&mail='+mailId ;
		}else{
			showDebug("Sorry ! Your cart is empty .");
			return ;
		}
		
		
	}
	//alert(shippingStr);
	//return ;
	myconn = new ajaxprocess();				
	var resultFunction = function(resultObject) 
	{ 
		var response_prev = resultObject.responseText;	
		var response = returnHTML(response_prev);	
		//alert(response);
		//if(window.firefox )console.log(response);
		response  = trim(response);
		var newOrderCode = response ;
		set_cookie ( "orderId", newOrderCode ,"","/","www.edubotix.in");
		set_cookie ( "itemCount", 0 ,"","/","www.edubotix.in");
		
		alert("Your order is submitted successfully .We will contact you soon .");	
		showDebug("Your order is submitted successfully .We will contact you soon .");	
		location.href = "roboshop.html" ;
		
		return;
		
	};
	myconn.ajaxclass('get',actionControllerPath+'?opCode=submitOrder'+str ,"null",resultFunction); 	
	return;
}

//PURPOSE : Function to get list of all products from DB
function getProductList(){
	window.itemMainArr.length = 0; 
	myconn = new ajaxprocess();				
	var resultFunction = function(resultObject) 
	{ 
		var response_prev = resultObject.responseText;	
		var response = returnHTML(response_prev);	
		//alert(response);
		if(window.firefox )console.log(response);
			
		return;
		
	};
	myconn.ajaxclass('get',actionControllerPath+'?opCode=getProductList' ,"null",resultFunction); 	
	return;
}

//PURPOSE : Function to change css in real time of any element on occurence of any event . 	
function changeCSS(callFor,ele,event){
	if(callFor == 'productIntroCol'){
		if(event == 'mouseover'){
			ele.style.borderColor = '#24664f' ;
		}
		else{
			ele.style.borderColor = '#ffffff' ;
		}
	}
}

//PURPOSE : Function to get list of all products from DB
function getHTML(){
	myconn = new ajaxprocess();				
	var resultFunction = function(resultObject) 
	{ 
		var response_prev = resultObject.responseText;	
		var response = returnHTML(response_prev);	
		//alert(response);
		if(window.firefox )console.log(response);
			
		return;
		
	};
	myconn.ajaxclass('get','modules/dd.php?opCode=getHTML' ,"null",resultFunction); 	
	return;
}

//Coder: Vijaita Khandelwal
//Purpose: Function to create javascript object collection array for all products .
function addItemToGlobalCollection(){
		getProductList();
		return ;
		/* window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("",0,"");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("turtle",5000,"prod_turtle.html","DY01");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("aviator",35000,"prod_aviator.html","AVT01");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("abacus",20000,"prod_abacus.html","ABS01");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("teach-pendent",20000,"prod_teachPendeant.html","RA06");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("servo_rotatingPlatform",15000,"prod_rotatingPlatform.html","RA05");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("robotic_manipulator",49000,"prod_manipulator.html","DY04");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("servo_gripper",1750,"prod_servoGripper.html","GP02");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("servo_gripperwithtilt",3000,"prod_servoGripper_tilt.html","GP01");
		
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("digitalSwtich",750,"prod_digitalSwitch.html","IO01");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("digitalPowerSupply",1800,"prod_digitalPowerSupply.html","PS01");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("oscilloscope",9000,"prod_Osilloscope.html","OS01");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("biped",7500,"prod_biped.html","DY02");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("hexapod",20000,"prod_hexapod_12servo.html","DY03");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("hexapod-3servo",7500,"prod_hexapod_3servo.html","DY06");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("turtle-tracks",5000,"prod_turtleTracks.html","DY05");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("usb to serial",650,"prod_UsbToSerial.html","IF01");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("serial_module",300,"prod_SerialModule.html","IF02");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("Cellphone_Controller",650,"prod_CellphoneController.html","IF03");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("parallel port programmer",250,"prod_ParallelPortProgrammer.html","IF04");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("switch control",150,"prod_SwitchControl.html","IO02");
		
		//SENSORS
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("sensor_bump",300,"prod_sensor_bump.html","SN14");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("sensor_light",125,"prod_sensor_light.html","SN01");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("sensor_line",250,"prod_sensor_line.html","SN02");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("sensor_obstruction",300,"prod_sensor_obstruction.html","SN03");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("sensor_sound",325,"prod_sensor_sound.html","SN04");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("sensor_temperature",300,"prod_sensor_temperature.html","SN05");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("sensor_accelerometer",600,"prod_sensor_accelerometer.html","SN06");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("sensor_pir",600,"prod_sensor_pir.html","SN07");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("sensor_magnet",300,"prod_sensor_magnet.html","SN08");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("sensor_ultrasonic",600,"prod_sensor_ultrasonic.html","SN09");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("sensor_gas",600,"prod_sensor_gas.html","SN10");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("sensor_color",600,"prod_sensor_color.html","SN12");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("Finger print",6999,"prod_sensor_fingerprint.html","SN21");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("line follower",250,"prod_sensor_linefollower.html","SN17");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("obstacle avoiding",300,"prod_sensor_obstacleavoider.html","SN18");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("light",125,"prod_sensor_lightseeker.html","SN16");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("sound",300,"prod_sensor_sound_new.html","SN19");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("Temperature",150,"prod_sensor_temperature_new.html","SN20");
		
		//WHEELS
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("wheel_plastic",50,"wheel_plastic.html","WH01");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("wheel_plasticRubber",60,"wheel_plasticRubber.html","WH03");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("wheel_track_big",60,"wheel_track_big.html","WH04");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("wheel_track_small",40,"wheel_track_small.html","WH05");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("wheel_rubber",500,"wheel_rubber.html","WH06");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("wheel_caster",25,"wheel_castor.html","WH02");
		//DISPLAY DEVICES
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("display_lcd_serial_16*2",400,"prod_serialLcd_16x2.html","DP02");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("display_lcdGraphical_serial_128*64",2000,"prod_serialLcd_128x64.html","DP04");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("display_lcd_16*2",200,"prod_lcd_16x2.html","DP01");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("board_lcdGraphical_dm_128*64",1100,"prod_lcd_DM_128x64.html","DP03");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("board_lcd_color",1750,"prod_lcd_color.html","DP05");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("board_lcd_color_touchscreen",2000,"prod_lcd_touchscreen.html","DP06");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("board_lcd_color_serial_touchscreen",2800,"prod_lcd_serial_touchscreen.html","DP07");
		
		//INPUT OUTPUT BOARDS
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("board_rapidIO",4000,"prod_rapidIO.html","DB02");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("board_basic",1250,"prod_basicBoard.html","DB03");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("DCmotor_controller",350,"prod_DCmotorController.html","MD04");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("servo_controller",2500,"prod_servoController.html","MD03");
		
		//MOTORS	
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("motor_dc_10",175,"prod_motor_dc_10.html","MT01");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("motor_dc_60",175,"prod_motor_dc_60.html","MT02");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("motor_dc_100",150,"prod_motor_dc_100.html","MT03");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("motor_dc_150",150,"prod_motor_dc_150.html","MT04");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("motor_dc_300",150,"prod_motor_dc_300.html","MT05");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("motor_stepper",500,"prod_motor_stepper.html","MT06");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("motor_servo_nylon_2",550,"prod_2.3Kgcm_servo_nylon.html","MT07");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("motor_servo_metal",1200,"prod_metalgear_servo_16.html","MT09");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("motor_servo_nylon_12",700,"prod_5Kgcm_servo_nylon_12.html","MT08");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("motor_servo_metal_2",850,"prod_2.3Kgcm_metal_servo.html","MT10");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("motor_sideshaft",900,"prod_motor_sideshaft_100.html","MT12");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("motor_RCbrushless",1500,"prod_motor_brushless.html","MT13");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("motor_dc_geared",1500,"prod_motor_DCGeared.html","MT14");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("motor_servo_quarterscale",1500,"prod_motor_Servo_quarterscale.html","MT11");
		//ACCESSORIES
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("ledAcidCharger",1500,"prod_leadBatteryCharger.html","AS05");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("motorMount",50,"prod_motorMount.html","RA01");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("ledAcidBattery",500,"prod_ledAcidBattery.html","BA01");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("chasis",150,"chasis.html","CS05");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("metal-chasis",250,"metal-chasis.html","CS06");
	    window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("chain_shackle",550,"chain_shackle.html","RA02");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("wheel_idler",30,"prod_wheel_idler.html","RA03");
		
	   //WIRELESS 
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("30meterwirelessModem",1250,"prod_30meterwirelessModem.html","WR01");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("100meterwirelessModem",1500,"prod_100meterwirelessModem.html","WR02");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("USB to wireless_100",2250,"prod_USB to wireless.html","WR03");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("USB to wireless_30",1750,"prod_USB to wireless_30meter.html","WR04");
		
	  //Mechanical Components
	    window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("Timing_pulley_small",300,"prod_TimingPulley_small.html","MC01");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("Metallic_Worm_Gear",650,"prod_MetallicWormGear.html","MC02");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("Timing_Pulley_Large",650,"prod_TimingPulley_large.html","MC03");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("Worm_Gear_set",150,"prod_WormGearSet.html","MC04");
	    window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("Sprocket",200,"prod_Sprocket.html","MC05");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("SpurGear_extralarge",250,"prod_SpurGear_extraLarge.html","MC06");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("Double_SpurGear",200,"prod_Double_SpurGear.html","MC07");
		window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("SpurGear_Large",150,"prod_SpurGear_Large.html","MC08");
	    window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("SpurGear_Small",125,"prod_SpurGear_Small.html","MC09");
	    window.itemMainArr[window.itemMainArr.length] = new addToItemCollection("Helical_Gear",200,"prod_HelicalGear.html","MC10"); */
		
}	
	

