function trim(stringToTrim) {
    return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function isValidEmailAddress(emailAddress)
{
    var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
    return pattern.test(emailAddress);
}


function checkEnterNewCommon(event,frm,urlEncrypted)
{

    var characterCode;
    characterCode = event.keyCode;
    //alert(frm);

    if(characterCode == 13)
    {
	if(frm=='frmChangePassword') {
	    changePassword(urlEncrypted);
	    return false;
	}
	else if(frm=='frmLogin') {
	    login();
	    return false;
	}
	else if(frm=='frmForgot') {
	    forgotPassword();
	    return false;
	}

    }
}

function changePassword(urlEncrypted)
{
    var flag=true;
    var password=$('#new_password').val();
    var confirmPassword=$('#confirm_password').val();
    if(password=='')
    {
	$('#password_span').html('Please enter password');
	flag=false;
    }
    else
    {
	if(password.length<6) {
	    $('#password_span').html('Minimum password length should be 6');
	    flag=false;
	}else {
	    $('#password_span').html('');
	}
    }
    if(confirmPassword=='')
    {
	$('#confirm_password_span').html('Please re-enter password');
	flag=false;
    }
    else
    {
	if(password!=confirmPassword)
	{
	    $('#confirm_password_span').html('Password mismatch');
	    flag=false;
	}
	else
	{
	    $('#confirm_password_span').html('');
	}
    }
    if(flag)
    {
	$('#result_span').html('<img src="'+baseUrl+'assets/images/ajax-loader.gif"/>');
	var postData = {
	    'password': password,
	    'confirmPassword': confirmPassword,
	    'urlEncrypted': urlEncrypted
	};
	$.ajax({
	    url: baseUrl + "index.php/home/changePasswordProcess",
	    type: "POST",
	    cache: false,
	    data: postData,
	    dataType: 'json',
	    success: function(response, status, XHR)
	    {
		if(response.result=='Password changed successfully')
		{
		    $('#new_password').val('');
		    $('#confirm_password').val('');
		    $('#result_span').css('color','green');
		}
		$('#result_span').html(response.result);
	    }
	});
    }
}
function forgotPassword()
{
    var email=$('#email_login_forgot').val();
    if(email=='')
    {
	$('#email_span_login_forgot').html('Please enter email ID');
	return false;

    }
    else
    {
	if(!isValidEmailAddress(email))
	{
	    $('#email_span_login_forgot').html('Please enter a valid email ID');
	    return false;
	}
	else
	{
	    $('#email_span_login_forgot').html('');
	}
    }
    $('#result_span_login_forgot').html('<img src="'+baseUrl+'assets/images/ajax-loader.gif"/>');
    var postData = {
	'email': email
    };
    $.ajax({
	url: baseUrl + "index.php/home/forgotPassword",
	type: "POST",
	cache: false,
	data: postData,
	dataType: 'json',
	success: function(response, status, XHR)
	{
	    $('#result_span_login_forgot').html(response.forgot_password);
	}
    });
}

function attribute_search_droplist_brand(  att_id )
{
    $('#category_right_comman').html('<div align="center"><img src="'+baseUrl+'assets/images/loading.gif"/></div>');
    var attributes_val=document.getElementsByName("attributes_val");
    var attributes_val_array=[];
    var brand_id=$('#brands').val();
    var j=0;
    for(var i=0;i<attributes_val.length;i++)
    {
	if(attributes_val[i].checked==true)
	{
	    attributes_val_array[j]=attributes_val[i].value;
	    j++;
	}
    }
    if(att_id!='')
	attributes_val_array[attributes_val_array.length]=att_id;

    var sortPrice= $('#sortByPrice').val();
    var min_value=$slider.slider("values", 0);
    var max_value=$slider.slider("values", 1);
    var postData = {
	'attributes': attributes_val_array,
	'brand_id': brand_id,
	'min_value': min_value,
	'max_value': max_value
    };
    $.ajax({
	url: baseUrl + "index.php/products/search/brandSearch",
	type: "POST",
	cache: false,
	data: postData,
	dataType: 'json',
	success: function(response, status, XHR) {
	    //alert(response.product_list_page);
	    $('#category_right_comman').html(response.product_list_page);
	}
    });
}

function attribute_search_droplist_keyword(keyword, cat_id, att_id)
{
    $('#category_right_comman').html('<div align="center"><img src="'+baseUrl+'assets/images/loading.gif"/></div>');
    var attributes_val=document.getElementsByName("attributes_val");
    var attributes_val_array=[];
    var brand_id=$('#brands').val();
    var j=0;
    for(var i=0;i<attributes_val.length;i++)
    {
	if(attributes_val[i].checked==true)
	{
	    attributes_val_array[j]=attributes_val[i].value;
	    j++;
	}
    }
    if(att_id!='')
	attributes_val_array[attributes_val_array.length]=att_id;

    var sortPrice= $('#sortByPrice').val();
    var min_value=$slider.slider("values", 0);
    var max_value=$slider.slider("values", 1);
    var postData = {
	'attributes': attributes_val_array,
	'cat_id': cat_id,
	'brand_id': brand_id,
	'min_value': min_value,
	'max_value': max_value,
	'keyword': keyword
    };
    $.ajax({
	url: baseUrl + "index.php/products/search/keywordSearch",
	type: "POST",
	cache: false,
	data: postData,
	dataType: 'json',
	success: function(response, status, XHR) {
	    //alert(response.product_list_page);
	    $('#category_right_comman').html(response.product_list_page);
	}
    });
}

function attribute_search_image_keyword(keyword, cat_id, att_id)
{
    $('#category_right_comman').html('<div align="center"><img src="'+baseUrl+'assets/images/loading.gif"/></div>');
    var attributes_val=document.getElementsByName("attributes_val");
    var attributes_val_array=[];
    var brand_id=$('#brands').val();

    var attributes_val_droplist=$('#attributes_val_droplist').val();

    if(attributes_val_droplist && attributes_val_droplist!='')
	attributes_val_array[attributes_val_array.length]=attributes_val_droplist;

    var j=0;
    for(var i=0;i<attributes_val.length;i++)
    {
	if(attributes_val[i].checked==true)
	{
	    attributes_val_array[j]=attributes_val[i].value;
	    j++;
	}
    }
    attributes_val_array[attributes_val_array.length]=att_id;
    var sortPrice= $('#sortByPrice').val();
    var min_value=$slider.slider("values", 0);
    var max_value=$slider.slider("values", 1);
    var postData = {
	'attributes': attributes_val_array,
	'cat_id': cat_id,
	'brand_id': brand_id,
	'min_value': min_value,
	'max_value': max_value,
	'keyword': keyword
    };
    $.ajax({
	url: baseUrl + "index.php/products/search/keywordSearch",
	type: "POST",
	cache: false,
	data: postData,
	dataType: 'json',
	success: function(response, status, XHR) {
	    //alert(response.product_list_page);
	    $('#category_right_comman').html(response.product_list_page);
	}
    });
}

function attribute_search_image_brand( att_id )
{
    $('#category_right_comman').html('<div align="center"><img src="'+baseUrl+'assets/images/loading.gif"/></div>');
    var attributes_val=document.getElementsByName("attributes_val");
    var attributes_val_array=[];
    var brand_id=$('#brands').val();

    var attributes_val_droplist=$('#attributes_val_droplist').val();

    if(attributes_val_droplist && attributes_val_droplist!='')
	attributes_val_array[attributes_val_array.length]=attributes_val_droplist;

    var j=0;
    for(var i=0;i<attributes_val.length;i++)
    {
	if(attributes_val[i].checked==true)
	{
	    attributes_val_array[j]=attributes_val[i].value;
	    j++;
	}
    }
    attributes_val_array[attributes_val_array.length]=att_id;
    var sortPrice= $('#sortByPrice').val();
    var min_value=$slider.slider("values", 0);
    var max_value=$slider.slider("values", 1);
    var postData = {
	'attributes': attributes_val_array,
	'brand_id': brand_id,
	'min_value': min_value,
	'max_value': max_value
    };
    $.ajax({
	url: baseUrl + "index.php/products/search/brandSearch",
	type: "POST",
	cache: false,
	data: postData,
	dataType: 'json',
	success: function(response, status, XHR) {
	    //alert(response.product_list_page);
	    $('#category_right_comman').html(response.product_list_page);
	}
    });
}

function attribute_search_keyword(keyword, cat_id)
{
    $('#category_right_comman').html('<div align="center"><img src="'+baseUrl+'assets/images/loading.gif"/></div>');
    var attributes_val=document.getElementsByName("attributes_val");
    var attributes_val_array=[];
    var brand_id=$('#brands').val();

    var attributes_val_droplist=$('#attributes_val_droplist').val();

    if(attributes_val_droplist!='')
	attributes_val_array[attributes_val_array.length]=attributes_val_droplist;

    var j=0;
    for(var i=0;i<attributes_val.length;i++)
    {
	if(attributes_val[i].checked==true)
	{
	    attributes_val_array[j]=attributes_val[i].value;
	    j++;
	}
    }
    var sortPrice= $('#sortByPrice').val();
    var min_value=$slider.slider("values", 0);
    var max_value=$slider.slider("values", 1);
    var postData = {
	'attributes': attributes_val_array,
	'cat_id': cat_id,
	'brand_id': brand_id,
	'min_value': min_value,
	'max_value': max_value,
	'keyword': keyword
    };
    $.ajax({
	url: baseUrl + "index.php/products/search/keywordSearch",
	type: "POST",
	cache: false,
	data: postData,
	dataType: 'json',
	success: function(response, status, XHR) {
	    //alert(response.product_list_page);
	    $('#category_right_comman').html(response.product_list_page);
	}
    });
}

function attribute_search_brand()
{
    $('#category_right_comman').html('<div align="center"><img src="'+baseUrl+'assets/images/loading.gif"/></div>');
    var attributes_val=document.getElementsByName("attributes_val");
    var attributes_val_array=[];
    var brand_id=$('#brands').val();

    var attributes_val_droplist=$('#attributes_val_droplist').val();

    if(attributes_val_droplist!='')
	attributes_val_array[attributes_val_array.length]=attributes_val_droplist;

    var j=0;
    for(var i=0;i<attributes_val.length;i++)
    {
	if(attributes_val[i].checked==true)
	{
	    attributes_val_array[j]=attributes_val[i].value;
	    j++;
	}
    }
    var sortPrice= $('#sortByPrice').val();
    var min_value=$slider.slider("values", 0);
    var max_value=$slider.slider("values", 1);
    var postData = {
	'attributes': attributes_val_array,
	'brand_id': brand_id,
	'min_value': min_value,
	'max_value': max_value
    };
    $.ajax({
	url: baseUrl + "index.php/products/search/brandSearch",
	type: "POST",
	cache: false,
	data: postData,
	dataType: 'json',
	success: function(response, status, XHR) {
	    //alert(response.product_list_page);
	    $('#category_right_comman').html(response.product_list_page);
	}
    });
}

function search_brand_keyword(keyword, cat_id, brand_id)
{
    $('#category_right_comman').html('<div align="center"><img src="'+baseUrl+'assets/images/loading.gif"/></div>');
    var attributes_val=document.getElementsByName("attributes_val");



    var attributes_val_array=[];

    var attributes_val_droplist=$('#attributes_val_droplist').val();

    if(attributes_val_droplist!='')
	attributes_val_array[attributes_val_array.length]=attributes_val_droplist;


    var j=0;
    for(var i=0;i<attributes_val.length;i++)
    {
	if(attributes_val[i].checked==true)
	{
	    attributes_val_array[j]=attributes_val[i].value;
	    j++;
	}
    }
    var sortPrice= $('#sortByPrice').val();
    var min_value=$slider.slider("values", 0);
    var max_value=$slider.slider("values", 1);
    //alert(sortPrice);
    var postData = {
	'brand_id': brand_id,
	'cat_id': cat_id,
	'attributes': attributes_val_array,
	'min_value': min_value,
	'max_value': max_value,
	'keyword': keyword
    };
    $.ajax({
	url: baseUrl + "index.php/products/search/keywordSearch",
	type: "POST",
	cache: false,
	data: postData,
	dataType: 'json',
	success: function(response, status, XHR) {

	    $('#category_right_comman').html(response.product_list_page);
	}
    });
}

function keyword_search_ajax(keyword,cat_id, pageSize, page_no, sortPrice )
{
    $('#category_right_comman').html('<div align="center"><img src="'+baseUrl+'assets/images/loading.gif"/></div>');
    var attributes_val=document.getElementsByName("attributes_val");
    var attributes_val_array=[];
    var brand_id=$('#brands').val();

    var attributes_val_droplist=$('#attributes_val_droplist').val();

    if(attributes_val_droplist!='')
	attributes_val_array[attributes_val_array.length]=attributes_val_droplist;

    var j=0;
    for(var i=0;i<attributes_val.length;i++)
    {
	if(attributes_val[i].checked==true)
	{
	    attributes_val_array[j]=attributes_val[i].value;
	    j++;
	}
    }
    //var sortPrice= $('#sortByPrice').val();
    var min_value=$slider.slider("values", 0);
    var max_value=$slider.slider("values", 1);

    var postData = {
	'attributes': attributes_val_array,
	'catId': cat_id,
	'brand_id': brand_id,
	'min_value': min_value,
	'max_value': max_value,
	'keyword': keyword,
	'sortPrice': sortPrice,
	'page_no': page_no,
	'pageSize': pageSize
    };
    $.ajax({
	url: baseUrl + "index.php/products/search/keywordSearch",
	type: "POST",
	cache: false,
	data: postData,
	dataType: 'json',
	success: function(response, status, XHR)
	{
	    $('#category_right_comman').html(response.product_list_page);
	}
    });
}

function brand_search_ajax( brand_id, pageSize, page_no, sortPrice )
{
    $('#category_right_comman').html('<div align="center"><img src="'+baseUrl+'assets/images/loading.gif"/></div>');
    var attributes_val=document.getElementsByName("attributes_val");
    var attributes_val_array=[];
    //var brand_id=$('#brands').val();

    var attributes_val_droplist=$('#attributes_val_droplist').val();

    if(attributes_val_droplist!='')
	attributes_val_array[attributes_val_array.length]=attributes_val_droplist;

    var j=0;
    for(var i=0;i<attributes_val.length;i++)
    {
	if(attributes_val[i].checked==true)
	{
	    attributes_val_array[j]=attributes_val[i].value;
	    j++;
	}
    }
    //var sortPrice= $('#sortByPrice').val();
    var min_value=$slider.slider("values", 0);
    var max_value=$slider.slider("values", 1);

    var postData = {
	'attributes': attributes_val_array,
	'brand_id': brand_id,
	'min_value': min_value,
	'max_value': max_value,
	'sortPrice': sortPrice,
	'page_no': page_no,
	'pageSize': pageSize
    };
    $.ajax({
	url: baseUrl + "index.php/products/search/brandSearch",
	type: "POST",
	cache: false,
	data: postData,
	dataType: 'json',
	success: function(response, status, XHR)
	{
	    $('#category_right_comman').html(response.product_list_page);
	    $('#active_link').html('<a href="'+baseUrl+'">Home</a> &gt; '+response.brand_name);

	}
    });
}

function ReplaceAll(Source,stringToFind,stringToReplace){

    var temp = Source;

    var index = temp.indexOf(stringToFind);

    while(index != -1){

	temp = temp.replace(stringToFind,stringToReplace);

	index = temp.indexOf(stringToFind);

    }

    return temp;

}

/*
 * This function is used for submitting the search on Enter
 */
function submitSearch(event){

    var characterCode
    characterCode = event.keyCode;

    if(characterCode == 13){
	headerSearch();
    }
}


function headerSearch()
{
    var searchText=$('#searchText').val();
    //var searchCategory=$('#searchCategory').val();
    var searchCategory = $(".searchUL li:eq(0) span").html();
    //alert(searchCategory);
    if( searchCategory == null )
    {
	searchCategory = '';
    }

    if( searchText == '' || searchText == 'Search for Products' )
    {
	alert('Please enter your keyword');
	return false;
    }

    searchText = ReplaceAll(searchText,"(","&#040;");
    searchText = ReplaceAll(searchText,")","&#041;");
    searchText = ReplaceAll(searchText,"/","&#047;");

    searchText = ReplaceAll(searchText," ","&#032;");
    if(searchCategory == '')
    {
	window.location.href= baseUrl+'index.php/products/search/keyword/'+encodeURIComponent(searchText);
    }
    else
    {
	window.location.href= baseUrl+'index.php/products/search/keyword/'+encodeURIComponent(searchText)+'/'+searchCategory;
    }
}

function login()
{
    var flag=true;
    var email=$('#email_login').val();
    var password=$('#password_login').val();
    if(email=='')
    {
	$('#email_span_login').html('Please enter email');
	flag=false;
    }
    else
    {
	$('#email_span_login').html('');
    }
    if(password=='')
    {
	$('#password_span_login').html('Please enter password');
	flag=false;
    }
    else
    {
	$('#password_span_login').html('');
    }
    if(flag)
    {
	$('#result_span_login').html('<img src="'+baseUrl+'assets/images/ajax-loader.gif"/>');
	var postData = {
	    'email': email,
	    'password': password
	};
	$.ajax({
	    url: baseUrl + "index.php/home/loginProcess",
	    type: "POST",
	    cache: false,
	    data: postData,
	    dataType: 'json',
	    success: function(response, status, XHR)
	    {
		if(response.login==true)
		{
		    window.location.href=baseUrl;
		}
		else
		{
		    $('#result_span_login').html(response.login);
		}
	    }
	});
    }
}
function displayLogin()
{
    var height=$('body').height();
    $('#fade').css('height',height);
    $('#fade').show();
    $('#login1').fadeIn("slow");
    var postData = {};

    $.ajax({
	url: baseUrl + "index.php/home/login",
	type: "POST",
	cache: false,
	data: postData,
	dataType: 'json',
	success: function(response, status, XHR) {
	    $('#login1').html(response.loginPage);
	}
    });
}
function closeLogin()
{
    $('#fade').fadeOut("slow");
    $('#login1').fadeOut("slow");
}
function signUp()
{
    $('#firstName_span').css("color","red");
    $('#lastName_span').css("color","red");
    var flag=true;
    var firstName=$('#firstName').val();
    var lastName=$('#lastName').val();
    var email=$('#email').val();
    var password=$('#password').val();
    var confirmPassword=$('#confirm_password').val();
    var mobile=$('#mobile').val();
    if(firstName=='')
    {
	$('#firstName_span').html('Please enter first name');
	flag=false;
    }
    else
    {
	$('#firstName_span').html('');
    }
    if(lastName=='')
    {
	$('#lastName_span').html('Please enter last name');
	flag=false;
    }
    else
    {
	$('#lastName_span').html('');
    }
    if(email=='')
    {
	$('#email_span').html('Please enter your email address');
	flag=false;
    }
    else
    {
	if(!isValidEmailAddress(email))
	{
	    $('#email_span').html('Please enter a valid email address');
	    flag=false;
	}
	else
	{
	    $('#email_span').html('');
	}

    }
    if(password=='')
    {
	$('#password_span').html('Please enter password');
	flag=false;
    }
    else
    {
	if(password.length<6) {
	    $('#password_span').html('Minimum password length should be 6');
	    flag=false;
	}else {
	    $('#password_span').html('');
	}
    }
    if(confirmPassword=='')
    {
	$('#confirm_password_span').html('Please re-enter password');
	flag=false;
    }
    else
    {
	if(password!=confirmPassword)
	{
	    $('#confirm_password_span').html('Password mismatch');
	    flag=false;
	}
	else
	{
	    $('#confirm_password_span').html('');
	}
    }
    if(mobile=='')
    {
	$('#mobile_span').html('Please enter mobile');
	flag=false;
    }
    else
    {
	if(mobile.length!=10)
	{
	    $('#mobile_span').html('Please enter 10 digit mobile number');
	    flag=false;
	}
	else
	{
	    $('#mobile_span').html('');
	}
    }
    if(flag)
    {
	$('#result_span').html('<img src="'+baseUrl+'assets/images/ajax-loader.gif"/>');
	var postData = {
	    'firstName': firstName,
	    'lastName': lastName,
	    'email': email,
	    'password': password,
	    'confirmPassword': confirmPassword,
	    'mobile': mobile
	};
	$.ajax({
	    url: baseUrl + "index.php/home/signUpProcess",
	    type: "POST",
	    cache: false,
	    data: postData,
	    dataType: 'json',
	    success: function(response, status, XHR)
	    {
		if(response.signUp=='User created successfully')
		{
		    $('#result_span').css('color','#0F0');
		    $('#email').val('');
		    $('#password').val('');
		    $('#confirm_password').val('');
		    $('#result_span').html(response.signUp);
		    var redirect=baseUrl+"index.php/products/category/index/1";
		    window.location.href=redirect;
		}
		$('#result_span').html(response.signUp);
	    }
	});
    }
}

function checkEnter(event)
{
    var characterCode
    characterCode = event.keyCode;
    if(characterCode == 13)
    {
	signUp();
	return false;
    }
}
function logout()
{
    $.ajax({
	url: baseUrl + "index.php/home/logout",
	type: "POST",
	cache: false,
	data: '',
	dataType: 'json',
	success: function(response, status, XHR) {
	    window.location.href=baseUrl;
	}
    });
}
function getMeSoon()
{
    var emailDeal= $('#emailDeal').val();
    var needDeal= $('#needDeal').val();
    if(emailDeal=='') {
	$('#emailDealSpan').html('Please enter email ID');
	return false;

    }
    else
    {
	if(!isValidEmailAddress(emailDeal))
	{
	    $('#emailDealSpan').html('Please enter a valid email ID');
	    return false;
	}
	else
	{
	    $('#emailDealSpan').html('');
	}

    }

    var postData = {
	'emailDeal': emailDeal,
	'needDeal': needDeal
    };
    $.ajax({
	url: baseUrl + "index.php/home/getMeSoon",
	type: "POST",
	cache: false,
	data: postData,
	dataType: 'json',
	success: function(response, status, XHR) {
	    if(response.getMeSoon=='Error') {
		$('#resultDealSpan').css('color','red');
	    }else {
		$('#resultDealSpan').css('color','green');
	    }
	    $('#resultDealSpan').html(response.getMeSoon);
	}
    });
}

function orderDetails(orderId,crmId,shpName,shpAddress1,shpCity,shpPostcode,shpPhoneno)
{


    var postData = {
	'orderId': orderId,
	'crmId': crmId,
	'shpName': shpName,
	'shpAddress1': shpAddress1,
	'shpCity': shpCity,
	'shpPostcode': shpPostcode,
	'shpPhoneno': shpPhoneno
    };
    $.ajax({
	url: baseUrl + "index.php/user/myaccount/orderDetails",
	type: "POST",
	cache: false,
	data: postData,
	dataType: 'json',
	success: function(response, status, XHR) {
	    $('#orderDetails'+orderId).html(response.orderDetailsPage);
	}


    });
}

function productImageSlider(imgName)
{
    var htmlDiv='<div id="wrap" style="top: 0px;  position: relative;" ><a href="'+imageUrl+'assets/img/big/'+imgName+'" class =';
    htmlDiv+='"cloud-zoom" id="zoom1" rel="adjustX: 40, adjustY: -1" style="position:relative;display:block;"><img  src="'+baseUrl;
    htmlDiv+='assets/img/big/'+imgName+'" alt="" style="display:block;"></a>';
    htmlDiv+='<div class="mousetrap" style="background-image: url(&quot;.&quot;); z-index: 999; position: absolute; width: 223px; height: 218px; left: 0px; ';
    htmlDiv+='top: 0px; cursor: move;" ></div>';

    htmlDiv+='<div style="position: absolute; left: 263px; top: -1px; width: 223px; height: 218px; background-image:';
    htmlDiv+='url("http://krishna.govasool/CI_govasool/assets/img/big/GVPRO022.jpg"); z-index: 99; background-position: 0px 0px;"';
    htmlDiv+='class="cloud-zoom-big" id="cloud-zoom-big"></div></div>';

    //$('span#mainImage').html(htmlDiv);

    $('span#mainImage div#wrap a').attr('href', imageUrl+'assets/img/big/'+imgName);
    $('span#mainImage div#wrap a img').attr('src', imageUrl+'assets/img/big/'+imgName);
    $('span#mainImage div#wrap div.cloud-zoom-big').css('background', 'url('+imageUrl+'assets/img/big/'+imgName+')');
}

function dropDown()
{

    $("div#cate_left_menu").slideUp("slow");
    $("div#main_left_nav_inner").slideDown("slow");
}

function dropUp()
{

    $("div#main_left_nav_inner").slideUp("slow");
    $("div#cate_left_menu").slideDown("slow");
}
function callSeasonDisplay(seasoncode)
{
    window.scrollTo(0, 0);

    //$('#light').fadeIn();
    $('#season').fadeIn();
    var height=$('body').height();
    $('#fade').css("height",height);

    var postData = {
	'seasoncode':seasoncode
    };
    $.ajax({
	url: baseUrl + "index.php/home/seasonDisplay",
	type: "POST",
	cache: false,
	data: postData,
	dataType: 'json',
	success: function(response, status, XHR) {
	    //$('#light').hide();
	    if (response.count > 0)
	    {
		$('#fade').show();
		$('#season').show();
		$('#season').fadeIn('slow');
		$('#season').html(response.templateView);

	    }

	}
    });
}
function seasonUserdatails()
{
    window.scrollTo(0, 0);
    var height=$('body').height();
    $('#fade').css("height",height);

    var postData = {};
    $.ajax({
	url: baseUrl + "index.php/home/seasonUserdatails",
	type: "POST",
	cache: false,
	data: postData,
	dataType: 'json',
	success: function(response, status, XHR) {


	    $('#fade').show();
	    $('#season').html('');
	    $('#season').fadeIn('slow');
	    $('#season').html(response.season_userform);



	}
    });
}
function getSeasonUserdatails()
{
    var season_username = $('#season_username').val();
    season_username = trim(season_username);

    var season_email = $('#season_email').val();
    season_email = trim(season_email);
    var season_mobile = $('#season_mobile').val();
    season_mobile = trim(season_mobile);
     if (season_username.length == 0)
    {
	$('#season_username_error').html('Please enter your Name');
	return false;
    }
    else if(season_email.length == 0)
    {
	$('#season_email_error').html('Please enter your Email Id');
	$('#season_username_error').html('');
	return false;
    }
    else if(!isValidEmailAddress(season_email))
    {
	$('#season_email_error').html('Please enter valid Email Id');
	$('#season_username_error').html('');
	return false;
    }
    else if(season_mobile.length == 0)
    {
	$('#season_mobile_error').html('Please enter your Mobile No.');
	$('#season_email_error').html('');
	$('#season_username_error').html('');
	return false;
    }
     else if(isNaN(season_mobile))
    {
	$('#season_mobile_error').html('Please enter only Numbers');
	$('#season_username_error').html('');
	$('#season_email_error').html('');
	return false;
    }
    else
	{
	    $('#season_username_error').html('');
	    $('#season_email_error').html('');
	    $('#season_mobile_error').html('');
	    var postData = {'season_username':season_username,'season_email':season_email,'season_mobile':season_mobile};
    $.ajax({
	url: baseUrl + "index.php/home/insertSeasonUserdatails",
	type: "POST",
	cache: false,
	data: postData,
	dataType: 'json',
	success: function(response, status, XHR) {

	    $('#fade').show();
	    $('#season').html('');
	    $('#season').fadeIn('slow');
	    $('#season').html(response.seasonCongratsMessage);



	}
    });
	}
}
function cGetSeasonUserdatails(baseUrl)
{

    var season_username = $('#season_username').val();
    season_username = trim(season_username);

    var season_email = $('#season_email').val();
    season_email = trim(season_email);
    var season_mobile = $('#season_mobile').val();
    season_mobile = trim(season_mobile);
    if (season_username.length == 0)
    {
	$('#season_username_error').html('Please enter your Name');
	return false;
    }
    else if(season_email.length == 0)
    {
	$('#season_email_error').html('Please enter your Email Id');
	$('#season_username_error').html('');
	return false;
    }
    else if(!isValidEmailAddress(season_email))
    {
	$('#season_email_error').html('Please enter valid Email Id');
	$('#season_username_error').html('');
	return false;
    }
    else if(season_mobile.length == 0)
    {
	$('#season_mobile_error').html('Please enter your Mobile No.');
	$('#season_email_error').html('');
	$('#season_username_error').html('');
	return false;
    }
     else if(isNaN(season_mobile))
    {
	$('#season_mobile_error').html('Please enter only Numbers');
	$('#season_username_error').html('');
	$('#season_email_error').html('');
	return false;
    }
    else
	{
	    $('#season_username_error').html('');
	    $('#season_email_error').html('');
	    $('#season_mobile_error').html('');

	    var postData = {'season_username':season_username,'season_email':season_email,'season_mobile':season_mobile};
    $.ajax({
	url: baseUrl + "index.php/home/cInsertSeasonUserdatails",
	type: "POST",
	cache: false,
	data: postData,
	dataType: '',
	success: function(response, status, XHR) {
	    
	   $("#output").html(response);
	}
    });
	}
}

function closeSeasonDisplay()
{
    $('#season').hide();
    $('#fade').hide();
    var postData = { };
     $.ajax({
	url: baseUrl + "index.php/home/setCookieSeasonVoucher",
	type: "POST",
	cache: false,
	data: postData,
	dataType: 'json',
	success: function(response, status, XHR) {

	}
    });
}

