$j = jQuery.noConflict();
// JavaScript Document



function getXMLObject()
{
    var requestObj;
    if(window.XMLHttpRequest) {
        requestObj = new XMLHttpRequest();
    }
    else if(window.ActiveXObject) {
        requestObj = new ActiveXObject("Microsoft.XMLHTTP");
    }
    return requestObj;
}

function voteLink(str, link_id)
{
    var requestObj = getXMLObject();

    if(requestObj)
    {
        var url="rate_link.php?str="+str +"&link_id="+link_id;

        requestObj.open("GET",url,true);
        requestObj.onreadystatechange = function()
        {
            if(requestObj.readyState==4 && requestObj.status == 200)
            {
                var str_image = requestObj.responseText;
                document.getElementById('lnk'+link_id).innerHTML=str_image;
                document.getElementById('rate_Lnk'+link_id).innerHTML='';
                document.getElementById('rate_Lnk1'+link_id).innerHTML='';
            }
        }
        requestObj.send(null);
    }
}
/*
function addPhoneLinks()
{
	if(document.getElementById('addlink').style.display=='none') {

		document.getElementById('addlink').style.display='block';
	} else {

		document.getElementById('addlink').style.display='none';
	}
}

function changeShip()
{
	document.cart_quantity.shippingID.value=document.cart_quantity.shipping[document.cart_quantity.shipping.selectedIndex].value;

}

function linkValidate()
{
	var strMsg = "Sorry! We can't complete your request. The following information is missing:\n\n";
	var msg="";
	if(document.getElementById('link_title').value=="")  {
		msg +="Link title should not be empty.\n";
	}
	if(document.getElementById('link').value=="")  {
		msg +="Link field should not be empty.\n";
	}
	/*if(document.getElementById('link_description').value=="")  {
		msg +="Link description should not be empty.";
	}
	if(msg!="")
	{
		alert(strMsg+msg);
		return false;
	}
	return true;
}



function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')
}
 */
function checkVideo(obj)
{

    var MsgStr = "Sorry, we cannot complete your request.\nPlease provide us the missing or incorrect information below:\n\n";
    var str="";

    if(obj.video_title.value=="") {
        str +="Video title shouldn't be blank.\n";
    }
    if(obj.video_url.value=="") {
        str +="Video URL shouldn't be blank.\n";
    }
    if(str!='') {

        alert(MsgStr + str);
        return false;
    } else {
        return true;
    }

}

function rate_video(rate_point, video_id)
{
    var requestObj = getXMLObject();

    if(requestObj)
    {
        var url="rate_video.php?rate_point="+rate_point +"&video_id="+video_id;

        requestObj.open("GET",url,true);
        requestObj.onreadystatechange = function()
        {
            if(requestObj.readyState==4 && requestObj.status == 200)
            {
                var str_image = requestObj.responseText;
                var imagename= str_image.split('~', 3);
                document.getElementById('current_rating').innerHTML = imagename[0];
                document.getElementById('rating_no').innerHTML ="("+ imagename[2] + " out of 5)";

                if(imagename[1]==0) {
                    document.getElementById('voted').innerHTML ="You have already rated this phone video.";
                }
            }
        }
        requestObj.send(null);
    }
}


function checkForm() {
    var error = 0;
    var error_message = "Errors have occured during the process of your form.\n\nPlease make the following corrections:\n\n";

    var review = document.product_reviews_write.review.value;
    /* if(document.product_reviews_write.review_title.value=="")
  {
  	 error_message = error_message + "* Review title shouldn't be empty.";
     error = 1;
  }*/
    if (review.length < 50) {
        error_message = error_message + "\n* The \'Review Text\' must have at least 50 characters.";
        error = 1;
    }

    /*if ((document.product_reviews_write.rating[0].checked) || (document.product_reviews_write.rating[1].checked) || (document.product_reviews_write.rating[2].checked) || (document.product_reviews_write.rating[3].checked) || (document.product_reviews_write.rating[4].checked)) {
  } else {
    error_message = error_message + "\n* You must rate the product for your review.";
    error = 1;
  }*/

    if (error == 1) {
        alert(error_message);
        return false;
    } else {
        return true;
    }
}



function selectionChange(delta,aid, grp,products_id)
{
    var requestObj = getXMLObject();
    if(requestObj)
    {
        var url="accessories_helper.php?query="+delta+","+aid+","+grp+","+products_id;

        requestObj.open("GET",url,true);
        requestObj.onreadystatechange = function()
        {
            if(requestObj.readyState==4 && requestObj.status == 200)
            {
                var sum = requestObj.responseText;
                // var strAccess =sum.split('~',2);
                document.getElementById('summary').innerHTML = sum;
            // document.getElementById('totalprice').innerHTML =strAccess[1];
            }
        }
        requestObj.send(null);
    }
}

function phone_finder_update(url, string)
{

    var xmlHttp = getXMLObject();

    document.getElementById('product_display').innerHTML='<div id="featuredProd"><div style="width:670px;"><div style="overflow:hidden;"><div style="width:6px; float:left;"></div></div><div align="center" style="overflow:hidden; "><div style="width:700px;"><div style="width:100%;height:225px; font-size:16px; color:#000000; margin-top:100px;"><img src="images/ajax_loader/ajax-loader.gif" alt="GSM Liberty" style="vertical-align:middle;" title="GSM Liberty" border="0" />&nbsp;Loading.........</div><div style="clear:both; height:9px;"></div></div><div style="clear:both"></div></div></div><div style="overflow:hidden;"><div style="width:11px; float:left;"></div><div style=" float:left; width:700px; height:13px;"></div><div style="width:11px; float:right;"></div></div><div style="clear:both; height:15px;"></div></div>';

    //alert('test');
    if(xmlHttp)
    {
        var manf = document.getElementById('manufacturer_id').value;
        url=url+"?counter="+string+"&mn="+manf;
        url=url+"&sid="+Math.random();
        //alert(url);
        xmlHttp.onreadystatechange=function()
        {
            if((xmlHttp.readyState==4) && (xmlHttp.status == 200))
            {
                phoneUupdateChanged(xmlHttp.responseText);

            }
        }
    }
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function phoneUupdateChanged(result)
{

    var strAccess = result.split('<>',9);

    var features_id = 'feature'+strAccess[3];
    var fea_idd = 'fea'+strAccess[3];
    var range_id = 'range'+strAccess[6];
    var r_id = 'r'+strAccess[6];
    var idsarr = strAccess[7].split(':');
    var idslen = idsarr.length;
    var imgname = "images/box.jpg";
    var bgcol = "#F2F2F4";

    document.getElementById('product_display').innerHTML = strAccess[0];
    //document.getElementById('featuresName').innerHTML = strAccess[1];
    //document.getElementById('noOfFeaturesPorducts').innerHTML = strAccess[2];

    if(strAccess[6])
    {
        document.getElementById(range_id).innerHTML = '<img src="'+strAccess[4]+'"  border="none" />';
        //document.getElementById(r_id).style.background = strAccess[5];

        for(var i=0; i<(idslen-1); i++)
        {
            var rowid = idsarr[i];


            document.getElementById('range'+rowid).innerHTML = '<img src="'+imgname+'"  border="none" />';
        //document.getElementById('r'+rowid).style.background = bgcol;
        }
    }
    else
    {

        document.getElementById(features_id).innerHTML = '<img src="'+strAccess[4]+'"  border="none" />';
    //document.getElementById(fea_idd).style.background = strAccess[5];
    }

    document.getElementById('dispTab').innerHTML = strAccess[8];

}

/*
function loadjscssfile(filename, filetype){
 if (filetype=="js"){ //if filename is a external JavaScript file
  var fileref=document.createElement('script')
  fileref.setAttribute("type","text/javascript")
  fileref.setAttribute("src", filename)
 }
 else if (filetype=="css"){ //if filename is an external CSS file
  var fileref=document.createElement("link")
  fileref.setAttribute("rel", "stylesheet")
  fileref.setAttribute("type", "text/css")
  fileref.setAttribute("href", filename)
 }
 if (typeof fileref!="undefined")
  document.getElementsByTagName("head")[0].appendChild(fileref)
}

 */

function unlock_mobile_tabs(url,str,divID)
{

    var requestObj = getXMLObject();

    document.getElementById('product_display').innerHTML='<div style="width:670px;;"><div style="overflow:hidden;"><div style="width:6px; float:left;"></div><div ></div><div style="width:6px; float:right;"></div></div><div align="center" style="overflow:hidden; "><div style="width:700px;"><div id="row" align="center" style="width:100%;height:225px; font-size:16px; color:#000000; margin-top:100px;" class="product-bottom123"><img src="images/ajax_loader/ajax-loader.gif" alt="GSM Liberty" style="vertical-align:middle;" title="GSM Liberty" border="0" />&nbsp;<span class="manuf">Loading.........</span></div></div></div><div style="clear:both;"></div></div>';



    if(requestObj)
    {
        mnid = document.getElementById('manufacturer_id').value;

        url=url+"?q="+str+"&m="+mnid;
        url=url+"&sid="+Math.random();

        requestObj.onreadystatechange=function()
        {
            if((requestObj.readyState==4) && (requestObj.status == 200))
            {

                chengedTab(requestObj.responseText);
            }
        }
    }

    requestObj.open("GET",url,true);
    requestObj.send(null);
}

function chengedTab(result)
{
    var strAccess = result.split('~', 2);
    document.getElementById('dispTab').innerHTML = strAccess[0];
    if (strAccess[1] != undefined)
        document.getElementById('product_display').innerHTML = strAccess[1];
    else
        document.getElementById('product_display').innerHTML = '<div>No products in this category.</div>';
    $j('#anchorDrop').trigger('change');

}


function calculate_checkout_shipping(url,str, thisvalue,divID)
{

    var xmlHttp = getXMLObject();

    //document.getElementById('product_display').innerHTML='<div style="width:723px;;"><div style="overflow:hidden;"><div style="width:6px; float:left;"><img src="images/left-edge.png" width="6" height="17" align="left" /></div><div style="background-color:#ffffff; float:left; width:711px; height:17px;"></div><div style="width:6px; float:right;"><img src="images/right-edge.png" width="6" height="17" align="right" /></div></div><div align="center" style="overflow:hidden; background:url(images/icons-grnd.gif) repeat-x left top #C6C8CA;"><div style="width:700px;"><div id="row" align="center" style="width:100%;height:225px; font-size:16px; color:#000000; margin-top:100px;" class="product-bottom123"><img src="images/ajax_loader/ajax-loader.gif" alt="GSM Liberty" style="vertical-align:middle;" title="GSM Liberty" border="0" />&nbsp;Loading.........</div></div></div><div style="clear:both;"></div></div>';

    if(xmlHttp)
    {
        url = url+"?q="+str+'&countryCode='+thisvalue;
        url = url+"&sid="+Math.random();
        //alert(url);
        xmlHttp.onreadystatechange=function()
        {
            if((xmlHttp.readyState==4) && (xmlHttp.status == 200))
            {  //alert(xmlHttp.responseText);
                var strShip = xmlHttp.responseText
                var strShipCal = strShip.split('~',2);
                $j('#shiping_prices').html(strShipCal[0])
                //document.getElementById('shipDiv').innerHTML = strShipCal[0];
                $j('#cartTotal').html('---')
                $j('#shipPrice').html()
                $j('#shiping_prices').trigger('change');
            }
        }
    }
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function shippingPriceDisplay(url,str, divID)
{

    var xmlHttp = getXMLObject();
    //alert(str);
    //alert(document.getElementById('shipping').value);
    if(xmlHttp)
    {
        url = url+"&qString="+str;
        url = url+"&sid="+Math.random();
        //alert(url);
        xmlHttp.onreadystatechange=function()
        {
            if((xmlHttp.readyState==4) && (xmlHttp.status == 200))
            {
                alert(xmlHttp.responseText);
                //shiping_prices(xmlHttp.responseText, divID);
                document.getElementById(shipPrice).innerHTML = result;


            }
        }
    }
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}


function get_accessories(strURL, str_id, divID)
{
    var requestObj = getXMLObject();
    if(requestObj)
    {
        var url = strURL+"?str_id="+str_id;
        url = url+"&sid="+Math.random();

        requestObj.open("GET",url,true);
        requestObj.onreadystatechange = function()
        {
            if(requestObj.readyState==4 && requestObj.status == 200)
            {
                var strResponse = requestObj.responseText;
                var divDispId =  divID+str_id;

                document.getElementById(divDispId).innerHTML = strResponse;
            }
        }
        requestObj.send(null);
    }
}

function getGSMModel()
{
    var manufacturers_id = document.getElementById('manu_id').value;

    var requestObj;
    requestObj = getXMLObject();

    if(requestObj)
    {
        var url="manufacturer_product.php?manufacturers_id="+manufacturers_id;
        var funlock = document.getElementById('f_unlock_2');
        requestObj.open("GET",url,true);
        requestObj.onreadystatechange = function()
        {
            if(requestObj.readyState==4 && requestObj.status==200)
            {
                document.getElementById('loader').style.display = 'none';
                document.getElementById('lbl1').innerHTML='Select your model';
                var obj = eval("(" + requestObj.responseText + ")");
                document.getElementById('modname1').innerHTML=obj.select;
                 if(document.getElementById('manufacturer-general')) {
                      document.getElementById('manufacturer-general').style.display = 'none';
                }
                if(document.getElementById('manufacturer-models')) {
                     document.getElementById('manufacturer-models').innerHTML=obj.list;
                }
               
            } else {
                document.getElementById('loader').style.display = 'block';;
            }
        }

        requestObj.send(null);
    }
}


function AllMobilePhones(url, path)
{
    var requestObj1;
    requestObj1 = getXMLObject();
    if(requestObj1)
    {
        var url = url;
    }
    requestObj1.open("GET",url,true);

    requestObj1.onreadystatechange = function()
    {
        if(requestObj1.readyState==4 && requestObj1.status==200)
        {

            window.location.href = path;
        }
    }
    requestObj1.send(null);
}

function popupWindow(url) {
    window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=450,height=150,screenX=150,screenY=150,top=150,left=150')
}


function removeDiv()
{
    document.getElementById('fly_main').style.display = "none";
}

/*
function setTab($jval)
{
	document.getElementById('tab').innerHTML = "";
	document.getElementById('tab').innerHTML = '<span class="b_unlock">Unlock your phone</span><a href="#" class="b_buy">Buy unlocked phones</a>';
}
 */
function searchRemove(x) {
    if ((x.value == 'find it here') || (x.value == 'find it here�')) {
        x.value = '';
    }
}

function searchField(x) {
    if (x.value == '') {
        x.value = 'find it here...';
    }
}


$j(document).ready(function(){
    $j('#tabs>div').hide();
    $j('#tabs>div:first').show();
    $j('#tabs>ul li:first').addClass('active');
    $j('#tabs>ul li a').click(function(){
        $j('#tabs>ul li').removeClass('active');
        $j(this).parent().addClass('active'); 
        var currentTab = $j(this).attr('href'); 
        $j('#tabs>div').hide();
        $j(currentTab).show();
        return false;
    });


    if ($j('#shiping_prices').get(0)){
        $j('#shiping_prices').change(function() {
            result = $j(this).val()
            if (result.indexOf('---') != -1) {
                var amount = result.split('---',2);
                var amountNumeric = parseFloat(amount[1].replace(/[^0-9\.]/g, ''))
                var totalNumeric = $j('#subtotal').html()
                totalNumeric = parseFloat(totalNumeric.replace(/[^0-9,\.]/g, '')) + amountNumeric
                $j('#shipPrice').html(amount[1])
                $j('#cartTotal').html("$" + totalNumeric)
            } else{
                $j('#cartTotal').html('---')
                $j('#shipPrice').html()
            }
        });
    }


    $j(function(){

        $j('form.f_top .inp').keydown(function(){
            var input = $j('.inp input').val();
            if ((input.length == 1) && ($j('.close').length == 0)) {
                $j(this).append($j('<div class="close"></div>'));
            } else if (input.length == 0) {
                $j('.close').remove();
            }
        });

        $j('form.f_top .inp').keyup(function(){
            var input = $j('.inp input').val();
            if ((input.length == 1) && ($j('.close').length == 0)) {
                $j(this).append($j('<div class="close"></div>'));
            } else if (input.length == 0) {
                $j('.close').remove();
            }
        });

        $j('form.f_top .close').live('click', function(){
            $j('.inp input').val('find it here..');
            $j(this).remove();
        });

        maxHeight = 220;
        minHeight = 17;
        $j('#rc .good_know .fold').mouseenter(
            function(){
                $j(this).siblings().stop().animate({
                    height: minHeight+"px"
                }, {
                    queue:false,
                    duration:300
                }, function(){

                }).find('a.title').removeClass('active');
                $j(this).stop().animate({
                    height: maxHeight+"px"
                }, {
                    queue:false,
                    duration:300
                }).find('a.title').addClass('active');
            });
        $j('#rc .good_know .fold:first').trigger('mouseenter');
        //$j('#rc .good_know .fold:first').animate({height: maxWidth+"px"}, { queue:false, duration:400 });

        //slider script starts here

        var previous_id = 1;
        $j('#slider').jCarouselLite({
            visible: 1,
            speed: 800,
            circular: true,
            auto:60000,
            btnGo: ["#sliderButton1", "#sliderButton2", "#sliderButton3"],
            beforeStart: function(li) {
                if(previous_id)
                    $j('#sliderButton'+previous_id).css('background-position', 'left top');
            },
            afterEnd: function(li) {
                var id = li.children('a').attr('href').substr(1,2);
                $j('#sliderButton'+id).css('background-position', 'right top');
                previous_id = id;
            },
            pauseOnHover: true
        });

        maxWidth = 87;
        minWidth = 0;
        $j("ul.pfinder li").mouseenter(
            function(){
                $j(this).siblings().animate({
                    width: minWidth+"px"
                }, {
                    queue:false,
                    duration:400
                });
                $j(this).siblings().children('div.in').animate({
                    width: minWidth+"px"
                }, {
                    queue:false,
                    duration:400
                });
                $j(this).animate({
                    width: maxWidth+"px"
                }, {
                    queue:false,
                    duration:400
                });
                $j(this).children('div.in').animate({
                    width: maxWidth+"px"
                }, {
                    queue:false,
                    duration:400
                });
            });

    
        $j('#mycarousel').jCarouselLite({
            btnNext: ".jcarousel-next",
            btnPrev: ".jcarousel-prev",
            circular: false,
            vertical: true,
            scroll: 1,
            visible: 2,
            mouseWheel: true
        });
			
			/* Unlocking form validate */
			
			$j('#cart_quantity').validate();
			
			/* Hide tool tips to start */
			
			$j(".tool_tip").hide();
			
			/* Behavoir of each area */
			
			// Unlocking action area
			
			$j("#give_hints").mouseover(function() {

				$j(".tool_tip").show("slow");

			});
			
			
			// Modals
			
			$j('#service_guarantee_modal').jqm();
		

        if($j('#summary_box').get(0)){
            $j(window).scroll(function() {
                var box = $j('#summary_box').get(0);
                var boxh = box.offsetHeight
                var h = $j(this).scrollTop()+boxh
                var limit = $j('#lc').get(0).offsetHeight
                if (h>limit && $j(box).css('position')=='fixed'){
                    $j(box).css('position','absolute').css('marginTop',$j(box).position().top+boxh)
                    $j(box).animate({
                        marginTop:limit-box.offsetHeight
                    })
                }
                if (h<=limit && $j(box).css('position')=='absolute'){
                    $j(box).css('marginTop',0).css('position','fixed')
                }
            });
        }


    });
});


function goforward()
{
	alert("test"); return false;
    var manufac_id = document.getElementById('manu_id').value;
    var modelid = document.getElementById('model_id').value;
    window.location.href="product_model_info.php?&model_id="+modelid;
}

//fucntion for getting price and turnaround on the basis of group which maps with carrier :: added by Sumit on 12th July,2010
function getAttributesValues(val1,val2,val3) {
$j('#carrier-attributes-loader').show();
  var attribute_id = val1;
	 var product_id = val2;
	 var tax_id = val3;
	 var url="group_attributes.php?attribute_id="+attribute_id+"&product_id="+product_id+"&tax_id="+tax_id;
		
		$j.ajax({ url: url, context: document.body, success: function(returneddata){
		 var content = returneddata.split("%-%-");
		$j('#carrier-attributes-loader').hide();	
		$j('#turnaroundId').show();
		$j('#priceId').show();
		$j('#turnaroundId2').show();	
		
		$j('#turnaroundId').html(content[0]);
		$j('#priceId').html(content[1]);
		$j('#turnaroundId2').html(content[2]);
		
      
      }});
	  	

}

//added by sumit
//function for submitting client email in case no imei is in the records
function submitEmail(productId){
	var imei=document.getElementById('unlock-imei-1').value;
	var userEmail=document.getElementById('userEmail').value;
	if(userEmail==''){
		alert('Please enter Email');
		return false;
	}else{		
		var url="user_attributes.php?email_id="+userEmail+"&product_id="+productId+"&imei="+imei;
		$j.ajax({url:url,context:document.body,success:function(returneddata){
			
			//alert(returneddata);		
			$j('#msg').show();		
					
				
		}});
	}
}

//fucntion for getting price and turnaround on the basis of group which maps with carrier :: added by Sumit on 12th July,2010
 function getAttributesValuesOld(val1,val2,val3) {
$j('#carrier-attributes-loader').show();
  var attribute_id = val1;
	 var product_id = val2;
	 var tax_id = val3;
	 var url="group_attributes_old.php?attribute_id="+attribute_id+"&product_id="+product_id+"&tax_id="+tax_id;
		
		$j.ajax({ url: url, context: document.body, success: function(returneddata){
		 var content = returneddata.split("%-%-");
		$j('#carrier-attributes-loader').hide();	
		$j('#turnaroundId').show();
		$j('#priceId').show();
		if(document.getElementById("turnaroundId2")) {
		  $j('#turnaroundId2').show();
    }  	
		
		$j('#turnaroundId').html(content[0]);
		$j('#priceId').html(content[1]);
		if(document.getElementById("turnaroundId2")) {
		$j('#turnaroundId2').html(content[2]);
		}
      
      }});
	  	

}

function getAttributesValuesNew(val1,val2,val3) {
var is_price_info_show_once = false;
if(!is_price_info_show_once) {
	$j('#helptext').html("<img src='images/ajax-loader.gif'/>");	

}
$j('#infoId').hide();


$j('#turnaroundId').html("<img src='images/ajax-loader.gif'/>&nbsp;&nbsp;&nbsp;");
$j('#priceId').html("<img src='images/ajax-loader.gif'/>&nbsp;&nbsp;&nbsp;");
$j('#infoId').hide();	
  var attribute_id = val1;
	 var product_id = val2;
	 var tax_id = val3;
	 var url="group_attributes_new.php?attribute_id="+attribute_id+"&product_id="+product_id+"&tax_id="+tax_id;
		
		$j.ajax({ url: url, context: document.body, success: function(returneddata){
		$j('#helptext').hide();
		is_price_info_show_once = true;
		 var content = returneddata.split("%-%-");
		//$j('#carrier-attributes-loader').hide();	
		$j('#priceInfo').show();		
		$j('#turnaroundId').html(content[0]);
		$j('#priceId').html(content[1]);		
		$j('#turnaroundid2').html(content[2]);
		$j('#infoId').show();	
		$j('#cartButton').attr("className", "btt btt-add-to-cart");  
		/*
		var imei_val =  $j('#imei').val();	
		var valid = is_valid_imei(imei_val);	
		if(imei_val != '' && valid) {			
			 $j('#cartButton').attr("className", "btt btt-add-to-cart");
		}
		*/
		
      
      }});
	
	  	
	  	

}

function is_valid_imei(str) {
	if(str.match('^[0-9]{15}$')) {
		return true;
	}
	else {
		return false;
	}
}

function closewindow(e)  {

	if(e.keyCode==27) {
		
		$j("#mod-method").hide();
		$j("#mod-time").hide();
		$j("#mod-type").hide();
		$j("#mod-guarantees").hide();
		$j("#mod-imei").hide();
	}

}

function check_compatabilty(url,val1,val2,val3) {
    $j('#compatable_results').html("<img src='images/ajax-loader.gif'/>");
	
	var finalUrl = url+"?carrier_to_be_used="+val1+"&product_model_id="+val2;
	$j.ajax({ url: finalUrl, context: document.body, success: function(returneddata){
	$j("#compatable_results").html(returneddata);		
	}
	})
	
	

	

}

// added for Nokia Unlock Page
function getGSMModelNokiaUnlcok(val)
{
   
   var manufacturers_id = val; 
 
   var url="manufacturer_product_nokia_unlock.php?manufacturers_id="+manufacturers_id;
   $j.ajax({ url: url, context: document.body, success: function(returneddata){
         
                
                $j("#phModel").html(returneddata);	
		
    }});
  
}

function close_nokia_unlock_window(e) {

	if(e.keyCode==27) {		
		$j("#mod-imei").hide();
	}
}

//added by Sumit on aug 17, 2011 
function reloadButton(pid,tid){		
    $j('#helptext').html("<img src='images/ajax-loader.gif'/>");
    $j('#helptext').show();
    //commented by sumit on aug 18, 2011
   // $j('#unlock-imei-1').val("");    
    $j('#cart_button_inside').html("<input type='button' id='cartButton' name='check-availability' class='btt btt-add-to-cart-new' onclick='fget_Attributes_Values_New2("+pid+","+tid+")' />");
    
    //added by sumit on aug 22,2011
    $j('#carrier_id').val('');
    
    $j('#helptext').hide();
}

///added by Sumit on Jul 7 2011 - for ajax imei functionality
function fget_Attributes_Values_New2(pId,taxId){
var imei=document.getElementById('unlock-imei-1').value;
	if(imei==''){
		alert('Please enter IMEI');
		return false;
	}else{
		if(imei==0){
		$j('#helptext').html("<p>Please enter phone IMEI for pricing and turnaround time</p>");
		$j('#helptext').show();
		$j('#priceInfo').hide();
		$j('#turnaroundId').html("&nbsp;&nbsp;&nbsp;");
		$j('#priceId').html("&nbsp;&nbsp;&nbsp;");
		$j('#cartButton').attr("className","btt btt-add-to-cart-disabled");return true;
		}
		//var imei=document.getElementById('unlock-imei-1').value;
		
		getAttributesValuesNew2(pId,taxId,imei);
	}
}


///added by Sumit on Jul 7 2011 - for ajax imei functionality
function getAttributesValuesNew2(val2,val3,imei){
    var is_price_info_show_once=false;
    if(!is_price_info_show_once){
	//added by sumit on aug 5, 2011
	    $j('#helptext').html("<img src='images/ajax-loader.gif'/>");
	    $j('#helptext').show();
    }
    $j('#infoId').hide();
    $j('#turnaroundId').html("<img src='images/ajax-loader.gif'/>&nbsp;&nbsp;&nbsp;");
    $j('#priceId').html("<img src='images/ajax-loader.gif'/>&nbsp;&nbsp;&nbsp;");
    $j('#infoId').hide();
    //var attribute_id=val1;
    var product_id=val2;
    var tax_id=val3;
    
    //var url="group_attributes_new2.php?product_id="+product_id+"&tax_id="+tax_id+"&imei="+imei;
    var url="group_attributes_newest.php?product_id="+product_id+"&tax_id="+tax_id+"&imei="+imei;
    $j.ajax({url:url,context:document.body,success:function(returneddata){
	$j('#helptext').hide();
	is_price_info_show_once=true;
	var content=returneddata.split("%-%-");
	//alert(returneddata);
	//alert(content);
	//changes made by sumit on aug 4, 2011
	//changes made by sumit on aug 5, 2011
	//returneddata=1;
	if(returneddata == 1){	/*error #1 - IMEI doesnot exist in our DB*/
	    $j('#err_imei_loader').html("<img src='images/ajax-loader.gif'/>");
		$j('#priceInfo').hide();
		$j('#infoId').hide();
		$j('#err_imei').hide();			
		$j('#noprice').show();
		$j('#err_imei_loader').hide();
	}else if(returneddata == 2){	/*error #2- invalid IMEI*/
		$j('#err_imei_loader').html("<img src='images/ajax-loader.gif'/>");
		$j('#priceInfo').hide();
		$j('#infoId').hide();
		$j('#err_imei').show();
		$j('#err_imei_loader').hide();
	}else{
	    $j('#priceInfo').show();
	    //$j('#helptext').html("<img src='images/ajax-loader.gif'/>");
	    //$j('#helptext').show();
		$j('#err_imei').hide();		
		$j('#turnaroundId').html(content[0]);
		$j('#priceId').html(content[1]);					
		
		//added by sumit on aug 16, 2011
		$j('#carrier_id').val(content[3]);
		
		//added by sumit on aug 9, 2011
		someString=content[1];
		newstr=someString.substr(1);		
		$j('#final_price').val(newstr);
		
		$j('#turnaroundid2').html(content[2]);
		
		$j('#infoId').show();
		$j('#cartButton').attr("className","btt btt-add-to-cart");
		//added by sumit on aug 8, 2011 
		$j('#cart_button_inside').html("<input type='submit' id='cartButton' name='submit' class='btt btt-add-to-cart' />");
		//added by sumit on aug 8, 2011
		//commented by sumit on aug 17, 2011
		//$j('#unlock-imei-1').attr('readonly', true);
		//added by sumit on aug 17, 2011
		$j('#unlock-imei-1').attr('class','correct_imei');
		$j('#helptext').hide();
	}
    }});
}//ef

