function ps_round(value, precision)
{
	if (typeof(roundMode) == 'undefined')
		roundMode = 2;
	if (typeof(precision) == 'undefined')
		precision = 2;
	
	method = roundMode;
	if (method == 0)
		return ceilf(value, precision);
	else if (method == 1)
		return floorf(value, precision);
	precisionFactor = precision == 0 ? 1 : Math.pow(10, precision);
	return Math.round(value * precisionFactor) / precisionFactor;
}

function	autoUrl(name, dest)
{
	var loc;
	var id_list;

	id_list = document.getElementById(name);
	loc = id_list.options[id_list.selectedIndex].value;
	if (loc != 0)
		location.href = dest+loc;
	return ;
}

function	autoUrlNoList(name, dest)
{
	var loc;

	loc = document.getElementById(name).checked;
	location.href = dest + (loc == true ? 1 : 0);
	return ;
}

/*
** show or hide element e depending on condition show
*/
function toggle(e, show)
{
	e.style.display = show ? '' : 'none';
}

function toggleMultiple(tab)
{
    var len = tab.length;

    for (var i = 0; i < len; i++)
        if (tab[i].style)
            toggle(tab[i], tab[i].style.display == 'none');
}

/**
* Show dynamicaly an element by changing the sytle "display" property
* depending on the option selected in a select.
*
* @param string $select_id id of the select who controls the display
* @param string $elem_id prefix id of the elements controlled by the select
*   the real id must be : 'elem_id'+nb with nb the corresponding number in the
*   select (starting with 0).
*/
function showElemFromSelect(select_id, elem_id)
{
	var select = document.getElementById(select_id);
	for (var i = 0; i < select.length; ++i)
	{
	    var elem = document.getElementById(elem_id + select.options[i].value);
		if (elem != null)
			toggle(elem, i == select.selectedIndex);
	}
}

/**
* Get all div with specified name and for each one (by id), toggle their visibility
*/
function openCloseAllDiv(name, option)
{
	var tab = $('*[name='+name+']');
	for (var i = 0; i < tab.length; ++i)
		toggle(tab[i], option);
}

/**
* Toggle the value of the element id_button between text1 and text2
*/
function toggleElemValue(id_button, text1, text2)
{
	var obj = document.getElementById(id_button);
	if (obj)
		obj.value = ((!obj.value || obj.value == text2) ? text1 : text2);
}

function addBookmark(url, title)
{
	if (window.sidebar)
		return window.sidebar.addPanel(title, url, "");
	else if ( window.external )
		return window.external.AddFavorite( url, title);
	else if (window.opera && window.print)
		return true;
	return true;
}

function writeBookmarkLink(url, title, text, img)
{
	var insert = '';
	if (img)
		insert = writeBookmarkLinkObject(url, title, '<img src="' + img + '" alt="' + escape(text) + '" title="' + escape(text) + '" />') + '&nbsp';
	insert += writeBookmarkLinkObject(url, title, text);
	document.write(insert);
}

function writeBookmarkLinkObject(url, title, insert)
{
	if (window.sidebar || window.external)
		return ('<a href="javascript:addBookmark(\'' + escape(url) + '\', \'' + escape(title) + '\')">' + insert + '</a>');
	else if (window.opera && window.print)
		return ('<a rel="sidebar" href="' + escape(url) + '" title="' + escape(title) + '">' + insert + '</a>');
	return ('');
}

function checkCustomizations()
{
	var tmp;
	var pattern = new RegExp(' ?filled ?');
	for (var i = 0; i < customizationFields.length; i++)
		/* If the field is required and empty then we abort */
		if (parseInt(customizationFields[i][1]) == 1 && $('#' + customizationFields[i][0]).val() == '' && !pattern.test($('#' + customizationFields[i][0]).attr('class')))
			return false;
	return true;
}

function ceilf(value, precision)
{
	if (typeof(precision) == 'undefined')
		precision = 0;
	var precisionFactor = precision == 0 ? 1 : Math.pow(10, precision);
	var tmp = value * precisionFactor;
	var tmp2 = tmp.toString();
	// If the current value has already the desired precision
	if (tmp2.indexOf('.') === false)
		return (value);
	if (tmp2.charAt(tmp2.length - 1) == 0)
		return value;
	return Math.ceil(tmp) / precisionFactor;
}

function floorf(value, precision)
{
	if (typeof(precision) == 'undefined')
		precision = 0;
	var precisionFactor = precision == 0 ? 1 : Math.pow(10, precision);
	var tmp = value * precisionFactor;
	var tmp2 = tmp.toString();
	// If the current value has already the desired precision
	if (tmp2.indexOf('.') === false)
		return (value);
	if (tmp2.charAt(tmp2.length - 1) == 0)
		return value;
	return Math.floor(tmp) / precisionFactor;
}

function setCurrency(id)
{
	$.ajax({
		type: 'POST',
		url: baseDir + 'changecurrency.php',
		data: 'id='+id,
		success: function(msg)
		{
			location.reload(true);
		}
	});
}


//Asses for Contact Form
// JavaScript Document



var phonecode = new Array();
phonecode[0] = "";
phonecode[1] = "61";
phonecode[2] = "43";
phonecode[3] = "32";
phonecode[4] = "1";
phonecode[5] = "45";
phonecode[6] = "420";
phonecode[7] = "49";
phonecode[8] = "33";
phonecode[9] = "52";
phonecode[10] = "64";
phonecode[11] = "47";
phonecode[12] = "34";
phonecode[13] = "41";
phonecode[14] = "44";
phonecode[15] = "1";
phonecode[16] = "";
phonecode[17] = "93";
phonecode[18] = "355";
phonecode[19] = "213";
phonecode[20] = "1-684";
phonecode[21] = "376";
phonecode[22] = "244";
phonecode[23] = "1-264";
phonecode[24] = "672";
phonecode[25] = "1-268";
phonecode[26] = "54";
phonecode[27] = "7";
phonecode[28] = "297";
phonecode[29] = "61";
phonecode[30] = "43";
phonecode[31] = "994";
phonecode[32] = "1-242";
phonecode[33] = "973";
phonecode[34] = "880";
phonecode[35] = "1-246";
phonecode[36] = "375";
phonecode[37] = "32";
phonecode[38] = "501";
phonecode[39] = "229";
phonecode[40] = "1-441";
phonecode[41] = "975";
phonecode[42] = "591";
phonecode[43] = "387";
phonecode[44] = "267";
phonecode[45] = "55";
phonecode[46] = "246";
phonecode[47] = "673";
phonecode[48] = "359";
phonecode[49] = "226";
phonecode[50] = "257";
phonecode[51] = "855";
phonecode[52] = "237";
phonecode[53] = "1";
phonecode[54] = "238";
phonecode[55] = "1-345";
phonecode[56] = "236";
phonecode[57] = "235";
phonecode[58] = "56";
phonecode[59] = "86";
phonecode[60] = "852";
phonecode[61] = "853";
phonecode[62] = "61";
phonecode[63] = "672";
phonecode[64] = "57";
phonecode[65] = "269";
phonecode[66] = "242";
phonecode[67] = "243";
phonecode[68] = "682";
phonecode[69] = "506";
phonecode[70] = "225";
phonecode[71] = "385";
phonecode[72] = "53";
phonecode[73] = "357";
phonecode[74] = "420";
phonecode[75] = "45";
phonecode[76] = "253";
phonecode[77] = "1-767";
phonecode[78] = "1-809";
phonecode[79] = "670";
phonecode[80] = "593";
phonecode[81] = "20";
phonecode[82] = "503";
phonecode[83] = "240";
phonecode[84] = "291";
phonecode[85] = "372";
phonecode[86] = "251";
phonecode[87] = "500";
phonecode[88] = "298";
phonecode[89] = "679";
phonecode[90] = "358";
phonecode[91] = "33";
phonecode[92] = "594";
phonecode[93] = "689";
phonecode[94] = "262";
phonecode[95] = "241";
phonecode[96] = "220";
phonecode[97] = "995";
phonecode[98] = "49";
phonecode[99] = "233";
phonecode[100] = "350";
phonecode[101] = "30";
phonecode[102] = "299";
phonecode[103] = "1-473";
phonecode[104] = "590";
phonecode[105] = "1-671";
phonecode[106] = "502";
phonecode[107] = "224";
phonecode[108] = "245";
phonecode[109] = "592";
phonecode[110] = "509";
phonecode[111] = "672";
phonecode[112] = "504";
phonecode[113] = "36";
phonecode[114] = "354";
phonecode[115] = "91";
phonecode[116] = "62";
phonecode[117] = "98";
phonecode[118] = "964";
phonecode[119] = "353";
phonecode[120] = "972";
phonecode[121] = "39";
phonecode[122] = "1-876";
phonecode[123] = "81";
phonecode[124] = "962";
phonecode[125] = "7";
phonecode[126] = "254";
phonecode[127] = "686";
phonecode[128] = "82";
phonecode[129] = "850";
phonecode[130] = "965";
phonecode[131] = "996";
phonecode[132] = "856";
phonecode[133] = "371";
phonecode[134] = "961";
phonecode[135] = "266";
phonecode[136] = "231";
phonecode[137] = "218";
phonecode[138] = "423";
phonecode[139] = "370";
phonecode[140] = "352";
phonecode[141] = "389";
phonecode[142] = "261";
phonecode[143] = "265";
phonecode[144] = "60";
phonecode[145] = "960";
phonecode[146] = "223";
phonecode[147] = "356";
phonecode[148] = "692";
phonecode[149] = "596";
phonecode[150] = "222";
phonecode[151] = "230";
phonecode[152] = "269";
phonecode[153] = "52";
phonecode[154] = "691";
phonecode[155] = "373";
phonecode[156] = "377";
phonecode[157] = "976";
phonecode[158] = "382";
phonecode[159] = "1-664";
phonecode[160] = "212";
phonecode[161] = "258";
phonecode[162] = "95";
phonecode[163] = "264";
phonecode[164] = "674";
phonecode[165] = "977";
phonecode[166] = "599";

phonecode[167] = "687";
phonecode[168] = "64";
phonecode[169] = "505";
phonecode[170] = "227";
phonecode[171] = "234";
phonecode[172] = "683";
phonecode[173] = "672";
phonecode[174] = "1-670";
phonecode[175] = "47";
phonecode[176] = "968";
phonecode[177] = "92";
phonecode[178] = "680";
phonecode[179] = "507";
phonecode[180] = "675";
phonecode[181] = "595";
phonecode[182] = "51";
phonecode[183] = "63";
phonecode[184] = "872";
phonecode[185] = "48";
phonecode[186] = "351";
phonecode[187] = "1";
phonecode[188] = "974";
phonecode[189] = "262";
phonecode[190] = "40";
phonecode[191] = "7";
phonecode[192] = "250";
phonecode[193] = "290";
phonecode[194] = "1-869";
phonecode[195] = "1-758";
phonecode[196] = "508";
phonecode[197] = "1-784";
phonecode[198] = "685";
phonecode[199] = "378";
phonecode[200] = "239";
phonecode[201] = "966";
phonecode[202] = "221";
phonecode[203] = "381";
phonecode[204] = "248";
phonecode[205] = "232";
phonecode[206] = "65";
phonecode[207] = "421";
phonecode[208] = "386";
phonecode[209] = "677";
phonecode[210] = "252";
phonecode[211] = "27";
phonecode[212] = "995";
phonecode[213] = "34";
phonecode[214] = "94";
phonecode[215] = "249";
phonecode[216] = "597";
phonecode[217] = "47";
phonecode[218] = "268";
phonecode[219] = "46";
phonecode[220] = "41";
phonecode[221] = "963";
phonecode[222] = "886";
phonecode[223] = "992";
phonecode[224] = "255";
phonecode[225] = "66";
phonecode[226] = "31";
phonecode[227] = "228";
phonecode[228] = "690";
phonecode[229] = "676";
phonecode[230] = "1-868";
phonecode[231] = "216";
phonecode[232] = "90";
phonecode[233] = "993";
phonecode[234] = "1-649";
phonecode[235] = "688";
phonecode[236] = "256";
phonecode[237] = "380";
phonecode[238] = "971";
phonecode[239] = "44";
phonecode[240] = "1";
phonecode[241] = "1";
phonecode[242] = "598";
phonecode[243] = "998";
phonecode[244] = "678";
phonecode[245] = "379";
phonecode[246] = "58";
phonecode[247] = "84";
phonecode[248] = "1-284";
phonecode[249] = "1-340";
phonecode[250] = "681";
phonecode[251] = "212";
phonecode[252] = "967";
phonecode[253] = "38";
phonecode[254] = "260";
phonecode[255] = "263";

function RegValue(FieldName) {

    if (FieldName.value == 'First Name' || FieldName.value == 'Your Name') {
        FieldName.value = '';
        FieldName.className = 'txtf';
    }
    else {
        FieldName.className = 'txtf';
    }
}

function RegValue1(FieldName) {

    if (FieldName.value == '') {
        FieldName.value = 'First Name';
        FieldName.className = 'txtfa';
    }
    else {
        FieldName.className = 'txtf';
    }
}
function RegValue2(FieldName) {

    if (FieldName.value == '') {
        FieldName.value = 'Your Name';
        FieldName.className = 'txtfa';
    }
    else {
        FieldName.className = 'txtf';
    }
}
function RegeValue2(FieldName) {

    if (FieldName.value == 'Last Name') {
        FieldName.value = '';
        FieldName.className = 'txtf';
    }
    else {
        FieldName.className = 'txtf';
    }
}
function RegeValue3(FieldName) {

    if (FieldName.value == '') {
        FieldName.value = 'Last Name';
        FieldName.className = 'txtfa';
    }
}

function RegeValue4(FieldName) {
    if (FieldName.value == 'City') {
        FieldName.value = '';
        FieldName.className = 'txtf';
    }
    else {
        FieldName.className = 'txtf';
    }
}

function RegeValue5(FieldName) {
    if (FieldName.value == '') {
        FieldName.value = 'City';
        FieldName.className = 'txtfa';
    }
}


function RegeValue6(FieldName) {
    if (FieldName.value == 'State') {
        FieldName.value = '';
        FieldName.className = 'txtf';
    }
    else {
        FieldName.className = 'txtf';
    }
}

function RegeValue7(FieldName) {
    if (FieldName.value == '') {
        FieldName.value = 'State';
        FieldName.className = 'txtfa';
    }
}

function RegeValue8(FieldName) {
    if (FieldName.value == 'Postal Code') {
        FieldName.value = '';
        FieldName.className = 'txtf';
    }
    else {
        FieldName.className = 'txtf';
    }
}

function RegeValue9(FieldName) {
    if (FieldName.value == '') {
        FieldName.value = 'Postal Code';
        FieldName.className = 'txtfa';
    }
}


function AriaValue(FieldName) {
    if (FieldName.value == 'Area Code') {
        FieldName.value = '';
        FieldName.className = 'txtf';
    }
    else {
        FieldName.className = 'txtf';
    }
}
function AriaValue1(FieldName) {
    if (FieldName.value == '') {
        FieldName.value = 'Area Code';
        FieldName.className = 'txtfa';
    }
    else {
        FieldName.className = 'txtf';
    }
}


function PhonValue(FieldName) {
    if (FieldName.value == 'Phone Number') {
        FieldName.value = '';
        FieldName.className = 'txtf';
    }
    else {
        FieldName.className = 'txtf';
    }
}
function PhonValue1(FieldName) {
    if (FieldName.value == '') {
        FieldName.value = 'Phone Number';
        FieldName.className = 'txtfa';
    }
    else {
        FieldName.className = 'txtf';
    }
}

function CellValue(FieldName) {
    if (FieldName.value == 'Mobile / Cell Phone Number' || FieldName.value == 'Mobile Number') {
        FieldName.value = '';
        FieldName.className = 'txtf';
    }
}
function CellValue1(FieldName) {
    if (FieldName.value == '') {
        FieldName.value = 'Mobile / Cell Phone Number';
        FieldName.className = 'txtfa';
    }
    else {
        FieldName.className = 'txtf';
    }
}
function CellValue2(FieldName) {
    if (FieldName.value == '') {
        FieldName.value = 'Mobile Number';
        FieldName.className = 'txtfa';
    }
    else {
        FieldName.className = 'txtf';
    }
}
function FaxValue(FieldName) {

    if (FieldName.value == 'Area Code') {
        FieldName.value = '';
        FieldName.className = 'txtf';
    }

    else if (FieldName.value == '') {
        FieldName.value = 'Area Code';
        FieldName.className = 'txtfa';
    }

    else {
        FieldName.className = 'txtf';
    }
}


function ContValue(FieldName) {

    if (FieldName.value == 'Your Mobile / Cell Phone') {
        FieldName.value = '';
        FieldName.className = 'txtf';
    }

    else if (FieldName.value == '') {
        FieldName.value = 'Your Mobile / Cell Phone';
        FieldName.className = 'txtfa';
    }

    else {
        FieldName.className = 'txtf';
    }
}


function desc1Value(FieldName) {

    if (FieldName.value == 'Your Mobile / Cell Phone') {
        FieldName.value = '';
        FieldName.className = 'txtf';
    }

    else if (FieldName.value == '') {
        FieldName.value = 'Your Mobile / Cell Phone';
        FieldName.className = 'txtfa';
    }

    else {
        FieldName.className = 'txtf';
    }
}

function check_count_change() {
    var val = document.dataform.country.options[document.dataform.country.selectedIndex].value;
    if (val != document.dataform.country_iso.value) {
        if (phonecode[document.dataform.country.selectedIndex] != '') {
            var reg = new RegExp("-");
            if (reg.test(phonecode[document.dataform.country.selectedIndex])) {
                var ph_arr = phonecode[document.dataform.country.selectedIndex].split('-');
                document.dataform.S_phone_country_code.value = '+' + ph_arr[0];
                document.dataform.S_phone_area_code.className = 'txtf';
                document.dataform.S_phone_area_code.value = ph_arr[1];
                document.dataform.S_cmobile.value = '+' + ph_arr[0];
            }
            else {
                document.dataform.S_phone_country_code.value = '+' + phonecode[document.dataform.country.selectedIndex];
                document.dataform.S_cmobile.value = '+' + phonecode[document.dataform.country.selectedIndex];
                document.dataform.S_phone_area_code.value = '';
            }
        }
        else {
            document.dataform.S_phone_country_code.value = '';
            document.dataform.S_cmobile.value = '';
        }
    }
    document.dataform.country_iso.value = val;
    document.dataform.S_country.value = document.dataform.country.options[document.dataform.country.selectedIndex].text;
}
function get_ccode() {
    document.dataform.S_fax_country_code.value = document.dataform.S_phone_country_code.value;
}
function get_acode() {
    document.dataform.S_fax_area_code.value = document.dataform.S_phone_area_code.value;
    document.dataform.PRODUCT.value = pcode;
}

function rem_default() {
    if (document.getElementById("txtTitle").value == "Looking for..." || document.getElementById("txtTitle").value == "Please write your products name here...") {
        document.getElementById("txtTitle").value = '';
    }
}
function boxtext() {
    if (document.getElementById("txtTitle").value == '') {
        document.getElementById("txtTitle").value = "Please write your products name here...";
    }
}
function style1() {
    if (document.dataform.S_name.value != 'First Name') {
        document.dataform.S_name.className = 'txtf';
    }
    if (document.dataform.S_name.value == '') {
        document.dataform.S_name.value = 'First Name'
        document.dataform.S_name.className = 'txtfa';
    }
    if (document.dataform.S_lname.value != 'Last Name') {
        document.dataform.S_lname.className = 'txtf';
    }
    if (document.dataform.S_lname.value == '') {
        document.dataform.S_lname.value = 'Last Name'
        document.dataform.S_lname.className = 'txtfa';
    }
    if (document.dataform.S_city.value == '') {
        document.dataform.S_city.value = 'City'
        document.dataform.S_city.className = 'txtfa';
    }
    if (document.dataform.S_city.value != 'City') {
        document.dataform.S_city.className = 'txtf';
    }
    if (document.dataform.S_state.value == '') {
        document.dataform.S_state.value = 'State'
        document.dataform.S_state.className = 'txtfa';
    }
    if (document.dataform.S_state.value != 'State') {
        document.dataform.S_state.className = 'txtf';
    }
    if (document.dataform.S_pin.value == '') {
        document.dataform.S_pin.value = 'Postal Code'
        document.dataform.S_pin.className = 'txtfa';
    }
    if (document.dataform.S_pin.value != 'Postal Code') {
        document.dataform.S_pin.className = 'txtf';
    }
    if (document.dataform.S_phone_area_code.value != 'Area Code') {
        document.dataform.S_phone_area_code.className = 'txtf';
    }
    if (document.dataform.S_phone_area_code.value == '') {
        document.dataform.S_phone_area_code.value = 'Area Code'
        document.dataform.S_phone_area_code.className = 'txtfa';
    }
    if (document.dataform.S_phone.value != 'Phone Number') {
        document.dataform.S_phone.className = 'txtf';
    }
    if (document.dataform.S_phone.value == '') {
        document.dataform.S_phone.value = 'Phone Number'
        document.dataform.S_phone.className = 'txtfa';
    }
    if (document.dataform.S_mobile.value != 'Mobile / Cell Phone Number') {
        document.dataform.S_mobile.className = 'txtf';
    }
    if (document.dataform.S_mobile.value == '') {
        document.dataform.S_mobile.value = 'Mobile / Cell Phone Number'
        document.dataform.S_mobile.className = 'txtfa';
    }
}
function referr_func() {
    document.getElementById('refer_detail').value = document.referrer;
}

function set() {
    var prd = '';
    //    var cart_details = '\n==========================================\n';
    //    for (var j = 0; j < quantity_count; j++) {
    //        prd = document.getElementById('product' + j).value;
    //        var qty = document.getElementById('qty' + j).value;
    //        if (qty) {
    //            prd = prd + ' x ' + qty;
    //        }
    //        cart_details = cart_details + prd + '\n';
    //    }
    //    cart_details = cart_details + '==========================================\n';
    //    if (prd == '') {
    //        document.getElementById('cart_details').value = '';
    //    }
    //    else {
    //        document.getElementById('cart_details').value = cart_details;
    //    }
    if (document.dataform.Description.value == "") {
        alert("Kindly describe your requirement.");
        document.dataform.Description.focus();
        return false;
    }
    if (document.dataform.Description.value.length > 4000) {
        alert("Kindly describe your requirement within the limit of 4000 characters.");
        document.dataform.Description.focus();
        return false;
    }
    var temp2 = document.dataform.Description.value;
    var temp3 = temp2.replace(/\s/gi, "");
    if (temp3.length == 0) {
        alert("Kindly describe your requirement.");
        document.dataform.Description.value = '';
        document.dataform.Description.focus();
        return false;
    }
    if (document.dataform.S_name.value.length == 0) {
        alert("Kindly enter your name.");
        document.dataform.S_name.focus();
        return false;
    }
    if (document.dataform.S_name.value == "First Name") {
        alert("Kindly enter your Name.");
        document.dataform.S_name.focus();
        return false;
    }
    var temp = document.dataform.S_name.value;
    var temp1 = temp.replace(/ /gi, "");
    if (temp1.length == 0) {
        alert("Kindly enter your name.");
        document.dataform.S_name.value = '';
        document.dataform.S_name.focus();
        return false;
    }
    var iChars = "!@#$%^&*()+=-[]1234567890\\\';,./{}|\":<>?";
    for (var i = 0; i < document.dataform.S_name.value.length; i++) {
        if (iChars.indexOf(document.dataform.S_name.value.charAt(i)) != -1) {
            alert("Kindly enter your name without special character & numeric value");
            document.dataform.S_name.value = '';
            document.dataform.S_name.focus();
            return false;
        }
    }
    if (document.dataform.S_email.value == '') {
        alert("Kindly enter your Email ID.");
        document.dataform.S_email.focus();
        return false;
    }
    if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.dataform.S_email.value))) {
        alert("Invalid Email ID. Kindly enter the correct ID.");
        document.dataform.S_email.focus();
        return (false);
    }
    if (document.dataform.S_organization.value != '') {
        var temp1 = document.dataform.S_organization.value.replace(/ /gi, "");
        if (temp1 == '') {
            document.dataform.S_organization.value = '';
        }
    }
    if (document.dataform.Website.value != '') {
        var temp1 = document.dataform.Website.value.replace(/ /gi, "");
        if (temp1 == '') {
            document.dataform.Website.value = '';
        }
    }
    if (document.dataform.S_streetaddress.value != '') {
        var temp1 = document.dataform.S_streetaddress.value.replace(/ /gi, "");
        if (temp1 == '') {
            document.dataform.S_streetaddress.value = '';
        }
    }
    if (document.dataform.S_city.value != '') {
        var temp1 = document.dataform.S_city.value.replace(/ /gi, "");
        if (temp1 == '') {
            document.dataform.S_city.value = '';
        }
    }
    if (document.dataform.S_state.value != '') {
        var temp1 = document.dataform.S_state.value.replace(/ /gi, "");
        if (temp1 == '') {
            document.dataform.S_state.value = '';
        }
    }
    if (document.dataform.S_pin.value != '') {
        var temp1 = document.dataform.S_pin.value.replace(/ /gi, "");
        if (temp1 == '') {
            document.dataform.S_pin.value = '';
        }
    }
    if ((document.dataform.S_country.value == "") || (document.dataform.country.options[document.dataform.country.selectedIndex].value == '')) {
        alert("Kindly select the Country.");
        document.dataform.country.focus();
        return false;
    }
    if (document.dataform.S_phone_country_code.value.length == 0) {
        alert("Kindly enter your country code .");
        document.dataform.S_phone_country_code.value = '';
        document.dataform.S_phone_country_code.focus();
        return false;
    }
	
	//Added for Phone Number compulsory
	   // if (document.dataform.S_phone.value.length == 0) {
//        alert("Kindly enter your phone number.");
//        document.dataform.S_phone.focus();
//        return false;
//    }
//    if (document.dataform.S_phone.value == "Phone Number") {
//        alert("Kindly enter your phone number.");
//        document.dataform.S_phone.focus();
//        return false;
//    }
//    var temp_ = document.dataform.S_phone.value;
//    var temp1_ = temp_.replace(/ /gi, "");
//    if (temp1_.length == 0) {
//        alert("Kindly enter your phone number.");
//        document.dataform.S_phone.value = '';
//        document.dataform.S_phone.focus();
//        return false;
//    }
		//Added for Phone Number compulsory Ended
	
    var country_phone_clnt = document.dataform.S_phone_country_code.value.replace(/ /gi, "");
    if (country_phone_clnt.length == 0) {
        alert("Kindly enter your country code other than space.");
        document.dataform.S_phone_country_code.value = '';
        document.dataform.S_phone_country_code.focus();
        return false;
    }
    var c_code = document.dataform.S_phone_country_code.value.replace(/-/gi, "");
    if ((isNaN(c_code) && (document.dataform.S_phone_country_code.value.length != 0)) && (document.dataform.S_phone_country_code.value.length != 0)) {
        alert("Kindly enter your country code for phone number in numeric form only.");
        document.dataform.S_phone_country_code.value = '';
        document.dataform.S_phone_country_code.focus();
        return false;
    }
    if (document.dataform.S_phone_area_code.value.length != 0 && document.dataform.S_phone_area_code.value != 'Area Code') {
        document.dataform.S_phone_area_code.value = document.dataform.S_phone_area_code.value.replace(/ /gi, "");
        if (isNaN(document.dataform.S_phone_area_code.value)) {
            alert("Kindly enter your area code in numeric form only");
            document.dataform.S_phone_area_code.value = '';
            document.dataform.S_phone_area_code.focus();
            return false;
        }
    }
    if (((document.dataform.S_phone.value.length == 0) && (document.dataform.S_mobile.value.length == 0)) || ((document.dataform.S_phone.value == "Phone Number") && (document.dataform.S_mobile.value == "Mobile / Cell Phone Number")) || ((document.dataform.S_phone.value == "Phone Number") && (document.dataform.S_mobile.value.length == 0)) || ((document.dataform.S_phone.value.length == 0) && (document.dataform.S_mobile.value == "Mobile / Cell Phone Number"))) {
        alert("Kindly enter your phone number or mobile number.");
        document.dataform.S_phone.value = '';
        document.dataform.S_phone.focus();
        return false;
    }
    else {
        if ((document.dataform.S_phone.value.length != 0) && (document.dataform.S_phone.value != "Phone Number")) {
            if (document.dataform.S_phone.value.length == 0) {
                alert("Kindly enter your phone number.");
                document.dataform.S_phone.value = '';
                document.dataform.S_phone.focus();
                return false;
            }
            if (document.dataform.S_phone.value == "Phone Number") {
                alert("Kindly enter your phone number.");
                document.dataform.S_phone.value = '';
                document.dataform.S_phone.focus();
                return false;
            }
            var phone_clnt = document.dataform.S_phone.value.replace(/ /gi, "");
            if (phone_clnt.length == 0) {
                alert("Kindly enter your phone number other than space.");
                document.dataform.S_phone.value = '';
                document.dataform.S_phone.focus();
                return false;
            }
            if (isNaN(document.dataform.S_phone.value)) {
                alert("Kindly enter your phone number in numeric only.");
                document.dataform.S_phone.value = '';
                document.dataform.S_phone.focus();
                return false;
            }
            var mobile_clnt = document.dataform.S_mobile.value.replace(/ /gi, "");
            if (mobile_clnt.length == 0) {
                alert("Kindly enter your mobile number other than space.");
                document.dataform.S_mobile.value = '';
                document.dataform.S_mobile.focus();
                return false;
            }
            if (isNaN(document.dataform.S_mobile.value) && (document.dataform.S_mobile.value != "Mobile / Cell Phone Number")) {
                alert("Kindly enter your mobile number in numeric only.");
                document.dataform.S_mobile.value = '';
                document.dataform.S_mobile.focus();
                return false;
            }
        }
        else {
            if ((document.dataform.S_mobile.value.length != 0) && (document.dataform.S_mobile.value != "Mobile / Cell Phone Number") || (document.dataform.S_mobile.value.length == 0) && (document.dataform.S_mobile.value != "Mobile / Cell Phone Number")) {
                if (document.dataform.S_mobile.value.length == 0) {
                    alert("Kindly enter your mobile number.");
                    document.dataform.S_mobile.value = '';
                    document.dataform.S_mobile.focus();
                    return false;
                }
                if (document.dataform.S_mobile.value == "Mobile / Cell Phone Number") {
                    alert("Kindly enter your moobile number.");
                    document.dataform.S_mobile.value = '';
                    document.dataform.S_mobile.focus();
                    return false;
                }
                var mobile_clnt = document.dataform.S_mobile.value.replace(/ /gi, "");
                if (mobile_clnt.length == 0) {
                    alert("Kindly enter your mobile number other than space.");
                    document.dataform.S_mobile.value = '';
                    document.dataform.S_mobile.focus();
                    return false;
                }
                if (isNaN(document.dataform.S_mobile.value)) {
                    alert("Kindly enter your mobile number in numeric only.");
                    document.dataform.S_mobile.value = '';
                    document.dataform.S_mobile.focus();
                    return false;
                }
            }
        }
    }
    //if (document.dataform.recaptcha_response_field.value.length == 0) {
//        alert("Kindly enter the code as appearing in the Image.");
//        document.dataform.recaptcha_response_field.focus();
//        return false;
//    }
    if (document.dataform.S_lname.value == "Last Name") {
        document.dataform.S_lname.value = "";
    }
    if (document.dataform.S_city.value == "City") {
        document.dataform.S_city.value = "";
    }
    if (document.dataform.S_state.value == "State") {
        document.dataform.S_state.value = "";
    }
    if (document.dataform.S_pin.value == "Postal Code") {
        document.dataform.S_pin.value = "";
    }
    if (document.dataform.S_phone_area_code.value == "Area Code") {
        document.dataform.S_phone_area_code.value = "";
    }
    if (document.dataform.S_cmobile.value == "Country Code") {
        document.dataform.S_cmobile.value = "";
    }
    if (document.dataform.S_phone.value == "Phone Number") {
        document.dataform.S_phone.value = "";
    }
    if (document.dataform.S_mobile.value == "Mobile / Cell Phone Number") {
        document.dataform.S_mobile.value = "";
    }
	return;
//	document.dataform.submit();
}


/*----For Description Text Status----*/
var fieldlimiter = {
    defaultoutput: "[int] characters remaining in your input limit.", //default message that gets output to statusid element
    uncheckedkeycodes: /(8)|(13)|(16)|(17)|(18)|(37)|(40)|(39)|(46)/, //keycodes that are not checked, even when limit has been reached. See http://www.javascriptkit.com/jsref/eventkeyboardmouse.shtml for avail keycodes
    limitinput: function(e, config) {
        var e = window.event || e
        var thefield = config.thefield
        var keyunicode = e.charCode || e.keyCode
        if (!this.uncheckedkeycodes.test(keyunicode)) {
            if (thefield.value.length >= config.maxlength) {
                if (e.preventDefault)
                    e.preventDefault()
                return false
            }
        }
    },
    showlimit: function(config) {
        var thefield = config.thefield
        var statusids = config.statusids
        var charsleft = config.maxlength - thefield.value.length
        if (charsleft < 0) //if user has exceeded input limit (possible if cut and paste text into field)
            thefield.value = thefield.value.substring(0, config.maxlength) //trim input
        for (var i = 0; i < statusids.length; i++) {
            var statusdiv = document.getElementById(statusids[i])
            if (statusdiv) //if status DIV defined
                statusdiv.innerHTML = this.defaultoutput.replace("[int]", Math.max(0, charsleft))
        }
        config.onkeypress.call(thefield, config.maxlength, thefield.value.length)
    },
    cleanup: function(config) {
        for (var prop in config) {
            config[prop] = null
        }
    },
    addEvent: function(targetarr, functionref, tasktype) {
        if (targetarr.length > 0) {
            var target = targetarr.shift()
            if (target.addEventListener)
                target.addEventListener(tasktype, functionref, false)
            else if (target.attachEvent)
                target.attachEvent('on' + tasktype, function() { return functionref.call(target, window.event) })
            this.addEvent(targetarr, functionref, tasktype)
        }
    },
    setup: function(config) {
        if (config.thefield) { //if form field exists
            config.onkeypress = config.onkeypress || function() { }
            config.thefield.value = config.thefield.value
            this.showlimit(config)
            this.addEvent([window], function(e) { fieldlimiter.showlimit(config) }, "load")
            this.addEvent([window], function(e) { fieldlimiter.cleanup(config) }, "unload")
            this.addEvent([config.thefield], function(e) { return fieldlimiter.limitinput(e, config) }, "keypress")
            this.addEvent([config.thefield], function() { fieldlimiter.showlimit(config) }, "keyup")
        }
    }
}

//settextvalue();f31();

//fieldlimiter.setup({
//    thefield: document.dataform.Description, //reference to form field
//    maxlength: 4000,
//    statusids: ["Description-status"], //id(s) of divs to output characters limit in the form [id1, id2, etc]. If non, set to empty array [].
//    onkeypress: function(maxlength, curlength) { //onkeypress event handler
//        //define custom event actions here if desired
//    }
//})


//Added for footer
//var time_start;
//			$(window).load(
//				function() {
//					time_start = new Date();
//				}
//			);
//			$(window).unload(
//				function() {
//					var time_end = new Date();
//					var pagetime = new Object;
//					pagetime.type = "pagetime";
//					pagetime.id_connections = "492";
//					pagetime.id_page = "18";
//					pagetime.time_start = "2011-07-05 15:49:28";
//					pagetime.token = "d14c5990da980e9d2585c206ce32188fed1064ee";
//					pagetime.time = time_end-time_start;
//					$.post("http://www.handcraft.co.in/statistics.php", pagetime);
//				}
//			);


    function getKeyCode(e) {
        var unicode = e.charCode ? e.charCode : e.keyCode;
        if (unicode == '13') {
            submitData();
        }
    }

    function numbersonlyInt(e) {
        var unicode = e.charCode ? e.charCode : e.keyCode
        if ((unicode != 8) && (unicode != 9) && (unicode != 37) && (unicode != 39) && (unicode != 46)) { //if the key isn't the backspace key (which we should allow)
            if (unicode < 48 || unicode > 57) //if not a number
                return false //disable key press
        }
    }

    function alphabetsOnly(e) {
        var unicode = e.charCode ? e.charCode : e.keyCode
        if ((unicode != 8) && (unicode != 9) && (unicode != 37) && (unicode != 39) && (unicode != 46)) { //if the key isn't the backspace key (which we should allow)
            if ((unicode < 97 || unicode > 122) && (unicode < 65 || unicode > 90)) //if not a number
                return false //disable key press
        }
    }

    function alphabetsWithSpace(e) {
        var unicode = e.charCode ? e.charCode : e.keyCode
        if ((unicode != 8) && (unicode != 9) && (unicode != 32) && (unicode != 37) && (unicode != 39) && (unicode != 46)) { //if the key isn't the backspace key (which we should allow)
            if ((unicode < 97 || unicode > 122) && (unicode < 65 || unicode > 90)) //if not a number
                return false //disable key press
        }
    }

    function alphanumbericOnly(e) {
        var unicode = e.charCode ? e.charCode : e.keyCode
        if ((unicode != 8) && (unicode != 9) && (unicode != 37) && (unicode != 39) && (unicode != 46)) { //if the key isn't the backspace key (which we should allow)
            if ((unicode < 97 || unicode > 122) && (unicode < 65 || unicode > 90) && (unicode < 48 || unicode > 57)) //if not a number
                return false //disable key press
        }
    }
	
	function textCounter(field,cntfield,maxlimit) {
		if (field.value.length > maxlimit) // if too long...trim it!
			field.value = field.value.substring(0, maxlimit);
			// otherwise, update 'characters left' counter
		else
			document.getElementById('Description-status').innerHTML = (maxlimit - field.value.length)+" characters remaining in your input limit.";
		}
		
		//Added to set the time in the div				//Added for set Share and Tweet and Google Plus on the product page$(document).ready(function () {		var pageUrl= document.URL;		if ($("#divShareTweetPlus").length > 0){			$.ajax({				type: "GET",				url: "share.php?pageUrl="+pageUrl,				success: processShareResponse			});		}	});		function processShareResponse(data)	{		$("#divShareTweetPlus").html(data);	}
		
		





  var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-24675704-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
