﻿    var $j=jQuery.noConflict();

    <!--   Hide     
      function   killErrors()   {     
      return   true;     
      }     
      window.onerror   =   killErrors;    
      //   -->     
    /*
    EASY TABS 1.2 Produced and Copyright by Koller Juergen
    www.kollermedia.at | www.austria-media.at
    Need Help? http:/www.kollermedia.at/archive/2007/07/10/easy-tabs-12-now-with-autochange
    You can use this Script for private and commercial Projects, but just leave the two credit lines, thank you.
    */
    //EASY TABS 1.2 - MENU SETTINGS
    //Set the id names of your tablinks (without a number at the end)
    var tablink_idname = new Array("tablink")
    //Set the id names of your tabcontentareas (without a number at the end)
    var tabcontent_idname = new Array("tabcontent") 
    //Set the number of your tabs in each menu
    var tabcount = new Array("7")
    //Set the Tabs wich should load at start (In this Example:Menu 1 -> Tab 2 visible on load, Menu 2 -> Tab 5 visible on load , Menu 3 -> Tab 1 visible on load)
    var loadtabs = new Array("1")  
    //Set the Number of the Menu which should autochange (if you dont't want to have a change menu set it to 0)
    var autochangemenu = 4;
    //the speed in seconds when the tabs should change
    var changespeed = 4;
    //should the autochange stop if the user hover over a tab from the autochangemenu? 0=no 1=yes
    var stoponhover = 1;
    //END MENU SETTINGS
    /*Swich EasyTabs Functions - no need to edit something here*/
    function easytabs(menunr, active) {if (menunr == autochangemenu){currenttab=active;}if ((menunr == autochangemenu)&&(stoponhover==1)) {stop_autochange()} else if ((menunr == autochangemenu)&&(stoponhover==0))  {counter=0;} menunr = menunr-1;for (i=1; i <= tabcount[menunr]; i++){document.getElementById(tablink_idname[menunr]+i).className='tab'+i;document.getElementById(tabcontent_idname[menunr]+i).style.display = 'none';}document.getElementById(tablink_idname[menunr]+active).className='tabactive';document.getElementById(tabcontent_idname[menunr]+active).style.display = 'block';}var timer; counter=0; var totaltabs=tabcount[autochangemenu-1];var currenttab=loadtabs[autochangemenu-1];function start_autochange(){counter=counter+1;timer=setTimeout("start_autochange()",1000);if (counter == changespeed+1) {currenttab++;if (currenttab>totaltabs) {currenttab=1}easytabs(autochangemenu,currenttab);restart_autochange();}}function restart_autochange(){clearTimeout(timer);counter=0;start_autochange();}function stop_autochange(){clearTimeout(timer);counter=0;}

    window.onload=function(){
    var menucount=loadtabs.length; var a = 0; var b = 1; do {easytabs(b, loadtabs[a]);  a++; b++;}while (b<=menucount);
    if (autochangemenu!=0){start_autochange();}
    }



    function getPrice()
    {

        var price = document.getElementById("lblPrice");
        var times = document.getElementById("lblTime");
        

        
        var pro =  document.getElementById("hidclassguid").value;
        
        var plist  = 1;
        plist = document.getElementById("ddlprofession").value.split(',');
        if(plist.length < 0)
		    pro =  document.getElementById("ddlprofession").value;
    		
        var start = document.getElementById("ddlStart").value;
        var end = document.getElementById("ddlEnd").value;

        if(pro=="00000000-0000-0000-0000-000000000000" || start=="" || end==""){
            price.value="0";
            times.value="0";
            return;    
        }
      
        var sl = parseInt(start);
        var el = parseInt(end);
     
        if(sl >= el){
            price.value="0";
            times.value="0";
            return;    
        }

        $j.ajax({
			    url: '/runescape/RSPLProductList.aspx?rd=' + Math.random(),
			    type: 'get',
			    data: 'operate=GetPriceByLevel&slevel=' + sl + '&elevel=' + el + '&pguid='+pro,
			    dataType: 'html',
			    success: function(html)
			    {

				    if(html!="")
				    {
				        var ary = html.split("|");
				        if(ary.length==2)
				        {
    				
				            var pric = parseFloat(ary[0]);
				            var d1 = parseFloat(document.getElementById("attack").value);
				            var d2 = parseFloat(document.getElementById("defence").value);
				            var d3 = parseFloat(document.getElementById("strength").value);
				            times.value = ary[1];
				     	    if(plist.length = 2)
						    {
						      pric =(Math.round(pric * plist[0]*100))/100;
						      times.value =FormatNumber(ary[1]*plist[1],0);
						    }
    				        
				            var priceshow = pric + (pric*d1)+(pric*d2)+(pric*d3);
				            price.value = FormatNumber(priceshow,2);
    				        
				        }
				    }else
				    {   
                        price.value="0";
                        times.value="0";   
				    }
			    }
		    }); 
    }

    function changeVisible()
    {
        var ddl = document.getElementById("ddlprofession");
        var txt = ddl.options[ddl.selectedIndex].text;
        
        var d1 = document.getElementById("attack");
        var d2 = document.getElementById("defence");
        var d3 = document.getElementById("strength");


        if(txt=="Attack")
        {
            d2.removeAttribute("disabled");
            d3.removeAttribute("disabled");
            d1.setAttribute("disabled","disabled");
        }else if(txt=="Defence")
        {
            d1.removeAttribute("disabled");
            d3.removeAttribute("disabled");
            d2.setAttribute("disabled","disabled");
        }else if(txt=="Strength")
        {
            d2.removeAttribute("disabled");
            d1.removeAttribute("disabled");
            d3.setAttribute("disabled","disabled");
        }else
        {
            d1.setAttribute("disabled","disabled");
            d2.setAttribute("disabled","disabled");
            d3.setAttribute("disabled","disabled");
        }
        d1.selectedIndex = 0;
        d2.selectedIndex = 0;
        d3.selectedIndex = 0;
    }

    function FormatNumber(intInput, count) {
                var c = 1;
                for (var i = 0; i < count; i++) {
                    c += "0";
                }
                c = parseInt(c);
                var strInput = (Math.round(intInput.toString().replace(/,/g, "") * c) / c);
                strInput = strInput.toFixed(count);
                return strInput;
            }
            
    //表单提交时填充值        
    function fillhidtxt()
    {
        //检查价格和时间
        var p = document.getElementById("lblPrice").value;
        var t = document.getElementById("lblTime").value;

        if(p=="" || p=="0" ||t==""||t=="0")
        {
            alert("Data error !");
            return false;
        }
        
        var hidpro = document.getElementById("txtprofession");
        var hidatk = document.getElementById("txtattack");
        var hiddfs = document.getElementById("txtdefence");
        var hidsth = document.getElementById("txtstrength");
        
        //职业
        var ddl = document.getElementById("ddlprofession");
        var txt = ddl.options[ddl.selectedIndex].text;
        hidpro.value = txt;
        //三维
        var ddlAttack =  document.getElementById("attack");
        var ddlDefence = document.getElementById("defence");
        var ddlStrength = document.getElementById("strength");
        ddl = document.getElementById("attack");
        txt = ddl.options[ddl.selectedIndex].text;
        hidatk.value = txt;
        
        ddl = document.getElementById("defence");
        txt = ddl.options[ddl.selectedIndex].text;
        hiddfs.value = txt;
        
        ddl = document.getElementById("strength");
        txt = ddl.options[ddl.selectedIndex].text;
        hidsth.value = txt;
        if(hidpro.value=='Attack')
        {
       if(ddlDefence.selectedIndex == 0 || ddlStrength.selectedIndex == 0)
       {
       alert("You must select the Defence Level and Strength Level!")
       return false;
       }
        }
        if(hidpro.value=='Defence')
        {
        if(ddlAttack.selectedIndex == 0 || ddlStrength.selectedIndex == 0)
       {
       alert("You must select the Attack Level and Strength Level!")
       return false;
       }
        }
        if(hidpro.value=='Strength')
        {
         if(ddlAttack.selectedIndex == 0 || ddlDefence.selectedIndex == 0)
       {
       alert("You must select the Attack Level and Defence Level!")
       return false;
       }
        }
        return true;
    }


    function mutiselectchange(idx)
    {
        var start = document.getElementById("sltstart"+idx).value;
        var end = document.getElementById("sltend"+idx).value;
        var pguid = document.getElementById("hidpguid"+idx).value;
        var tprice = document.getElementById("txtprice"+idx);
        var ttime = document.getElementById("txttime"+idx);
        if(start==""||end==""||pguid=="")
        {
        tprice.value=0;
				            ttime.value=0;
            return;
         }  
         
          var s = parseInt(start);
         var e = parseInt(end);
         if (isNaN(s) || isNaN(e)) {
	 	    tprice.value = 0;
	 	    ttime.value = 0;
	 	    return;
	     }
    	 
	     if (s >= e) {
	 	    tprice.value = 0;
	 	    ttime.value = 0;
		    alert("Start Level cannot be greater than End Level!")
	 	    return;
	     }
        
        //alert(start+"-"+end+"-"+pguid);
        
        $j.ajax({
			    url: '/runescape/RSPLProductList.aspx',
			    type: 'get',
			    data: 'operate=GetPriceByLevel&slevel=' + start + '&elevel=' + end + '&pguid='+pguid+'&rd=' + Math.random(),
			    dataType: 'html',
			    success: function(html)
			    {
				    if(html!="")
				    {
				        var ary = html.split("|");
				        if(ary.length==2)
				        {
				            tprice.value=ary[0];
				            ttime.value=ary[1];
				        }
				    }else{
					    tprice.value=0;
				            ttime.value=0;
				      }
			    }
		    }); 
    }

    function plleveltotal()
    {
    document.getElementById("txtdescrip").value="";
    
        var totalprice = 0;
        var totaltime = 0;
        
        for(var i=1;i<=1000;i++)
        {
            var next = document.getElementById("txtprice"+i);
            if(next==null)
                break;
        
            var p = document.getElementById("txtprice"+i);
            var t = document.getElementById("txttime"+i);
            
            totalprice += parseFloat(p.value);
            totaltime += parseFloat(t.value);
            
            var proname = document.getElementById("spanpro"+i).innerHTML;
            var txtdescrip = document.getElementById("txtdescrip");
            if(p.value!="0" && t.value!="0")
            {
                var sl = $j("#sltstart"+i+"").val();
                var el = $j("#sltend"+i+"").val();
                txtdescrip.value += proname+"("+sl+"-"+el+"), ";
            }
        }
        document.getElementById("txtprice").value = FormatNumber(totalprice,2);
        document.getElementById("txttime").value = FormatNumber(totaltime,2);
        
    }

    function chkchanged(idx)
    {
    //alert(idx);
        var chk = document.getElementById("chk"+idx);
        if(chk.checked==true)
        {
            var slt = document.getElementById("sltstart"+idx);
            slt.removeAttribute("disabled");
            slt = document.getElementById("sltend"+idx);
            slt.removeAttribute("disabled");
        }else
        {
            var slt = document.getElementById("sltstart"+idx);
            try{slt.selectedIndex =0;}catch(e){}
            slt.setAttribute("disabled","disabled");
            slt = document.getElementById("sltend"+idx);
            try{slt.selectedIndex =0;}catch(e){}
            slt.setAttribute("disabled","disabled");
            
            var txt = document.getElementById("txtprice"+idx);
            txt.value="0";
            txt = document.getElementById("txttime"+idx);
            txt.value="0";
        }
    }

    function checkmutiform()
    {
        var txt = $j("#txtprice").val();
        var tm =  $j("#txttime").val();
        if(txt==""||txt=="0.00"||tm=="")
        {
            alert("Data error!");
            return false;
        }
        return true;
    }


