// for loading window

xajax.callback.global.onRequest = function() {xajax.$('loadingbar').style.visibility = 'visible';}

xajax.callback.global.beforeResponseProcessing = function() {xajax.$('loadingbar').style.visibility='hidden';}



function processOnload() {



	if (selectedStyle == "ajax" && !ajax_supported()) {

		alert("Ajax not support...");

		// reload page with ajax disabled!!!

		location.href = '?switchstyle=basic';

        

        return;

	}



	if (selectedStyle == "") {
		var search_add = "";



		if (ajax_supported())

        {
			search_add = "switchstyle=standard";
        }

		else

        {
			search_add = "switchstyle=basic";
        }



		if (location.search == "")

			location.search = "?"+search_add;

		else 

			location.search = location.search+"&"+search_add;

            

        return;

	}

    

    // call the ajax function for the site to display

    //xajax_showSite(site);

}



// Check if AJAX is supported

function ajax_supported()

{

    result = (typeof xajax == "object");

    return result;

}



function updatePrice() {

        var amount_link = document.getElementById('amount');

        var amount = amount_link.value;

        var price_link = document.getElementById('price');

        var curconlink = document.getElementById('curconv');



        var price = '';



        switch(amount)

        {

            case '1':   price = '3.99'; break;

            case '2':   price = '7.98'; break;

            case '3':   price = '11.97'; break;

            case '4':   price = '15.96'; break;

            case '5':   price = '19.95'; break;

            case '10':   price = '39.90'; break;

        }

        

        var html = '<a href="http://www.x-rates.com/cgi-bin/cgicalc.cgi?value='+price + '&base=EUR" target="_blank" onclick="window.open(this.href, this.target, '+"height=350,width=550,resizable=yes,toolbar=no,scrollbars=no,statusbar=no,menubar=no,locationbar=no"+');return false;">EUR</a>';

        curconlink.innerHTML = html;



        price_link.value = price;



        var detail_text = document.moneybform.detail1_text.value;



        var temp_pos1 = detail_text.indexOf("get ");

        var temp_pos2 = detail_text.indexOf(" package(s)");



        var temp1 = detail_text.substring(0, temp_pos1 + 4);

        var temp2 = detail_text.substring(temp_pos2, detail_text.length);

        var temp = temp1 + amount + temp2;





        //alert(temp);



        document.moneybform.detail1_text.value = temp;

        document.moneybform.amount.value = price;

        document.moneybform.packages.value = amount;

        //return;

}



function setDispTime (timediff, gmt) {

//alert (gmt);

    var timediff = parseInt(timediff,10);

    var hour = parseInt(gmt.substring(4, 6),10);

    hour = hour + timediff;

    day = gmt.substring(0,3);



    if (hour < 0) {

        hour = 24 + hour;

        switch(day) {

            case "Mon":

                day = "Sun"

                break;

            case "Tue":

                day = "Mon"

                break;

            case "Wed":

                day = "Tue"

                break;

            case "Thu":

                day = "Wed"

                break;

            case "Fri":

                day = "Thu"

                break;

            case "Sat":

                day = "Fri"

                break;

            default:

                day = "Sat"

            break;

        }

    }



    if (hour >= 24) {

        hour = -24 + hour;

        switch(day) {

            case "Mon":

                day = "Tue"

                break;

            case "Tue":

                day = "Wed"

                break;

            case "Wed":

                day = "Thu"

                break;

            case "Thu":

                day = "Fri"

                break;

            case "Fri":

                day = "Sat"

                break;

            case "Sat":

                day = "Sun"

                break;

            default:

                day = "Mon"

            break;

        }

    }



    //alert (hour);

    //alert (oldtime.substring(3,5));



    if (hour > -10 && hour < 10)

        document.settings.time.value = day + " " + "0"+ hour + ":" + gmt.substring(7,9);

    else

        document.settings.time.value = day + " " + hour + ":" + gmt.substring(7,9);

}



function selectAll()

{

  void(d=document);

  void(el=d.getElementsByTagName('INPUT'));

  for(i=0;i<el.length;i++)

    void(el[i].checked=1) 

}



function unselectAll()

{

  void(d=document);

  void(el=d.getElementsByTagName('INPUT'));

  for(i=0;i<el.length;i++)

    void(el[i].checked=0) 

}



function setField(field_id, value) {

	var field = document.getElementById(field_id);	

	field.value = value;

}



function switchDisplay(hide, show) {

	document.getElementById(hide).style.display	= 'none';

	document.getElementById(show).style.display	= 'block';

}



function openwin(url,w,h) {

    new_window = window.open(url,'','toolbar=no,location=no,shopping=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=' + w + ',height=' + h,'');

}



function check (chars) {

        var anz=0, len=0, s;

        var msg = document.sms.messagetext.value;

        if (!chars) {

             chars = 459;

        }

        for (var i=0; i<msg.length; i++) {

                s = msg.charAt(i);

                var characterCode; //literal character code will be stored in this variable

/*                if(s && s.which){ //if which property of event object is supported (NN4)

                   s = s;

                   characterCode = s.which; //character code is contained in NN4's which property

                   alert ("No IE");

                }

                else{*/

                     characterCode = msg.charCodeAt(i); //character code is contained in IE's keyCode property

                     //alert(characterCode);

//                }

//                if(characterCode == 10) {

//                        alert("Character Code == 10");

//                }

                //alert("Character At: "+s);

                if (s=='€' || s=='~' || s=='^' || s=='\\' || s=='{' || s=='}' || s=='[' || s==']' || s=='|') {

                   if (anz>(chars-2)) {

                                 break

                        };

                   anz+=2;}

                else {

                    if (s=="\n" && characterCode==10) {

                            anz+=2;

                            //alert("Hier1");

                    }

                    else {

                            if (characterCode==13) {}

                            else {

                              if (anz>(chars-1)) {

                                  break

                              };

                              anz++;

                              }

//                        alert("Hier2");

                    }

                }

                len = i+1;

        }

        if (msg.length> len) {

                document.sms.messagetext.value = msg.substring(0,len);

        }

        document.sms.counter.value = chars-anz;

        if (anz > 160)

            if (anz > 306)

                document.sms.amountSMS.value = 3;

            else

                document.sms.amountSMS.value = 2;

        else

            document.sms.amountSMS.value = 1;



		if (navigator.appName =="Netscape" && parseInt(navigator.appVersion) <= 4) {

                document.captureEvents(Event.KEYPRESS);

                document.sms.messagetext.onkeypress = pruef;

           }

}



function count() {

   document.sms.counter.value = 459 - document.sms.messagetext.value.length;

   if (document.sms.messagetext.value.length > 459) {

      //disable Submit Button

      document.sms.submit.disabled=true;

   } else {

      //enable Submit Button

      document.sms.submit.disabled=false;

      //gifchange(okgif);

   }

   if (document.sms.messagetext.value.length > 160)

    if (document.sms.messagetext.value.length > 306)

        document.sms.amountSMS.value = 3;

    else

        document.sms.amountSMS.value = 2;

   else

        document.sms.amountSMS.value = 1;

}



function fillIn(x) {

    var text;

    text = x.options[x.selectedIndex].value;

    //alert(text);

    if (text != "--") {

        var pos = text.indexOf("|");

        document.sms.number.value = text;

        document.sms.messagetext.focus();

    }

}



function submitForm (x) {

	var formid = x;

	var form;

	

	form = document.getElementById(formid);

	form.submit();

}