// JavaScript Document
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->

<!--
// This function will auto-resize Iframes
function autofitIframe(id) 
     { 
          if (!window.opera && !document.mimeType && document.all && document.getElementById) 
          { 
               parent.document.getElementById(id).style.height=this.document.body.offsetHeight+"px"; 
          } 
          else if(document.getElementById) 
          { 
parent.document.getElementById(id).style.height=this.document.body.scrollHeight+"px" 
          } 
     } 

function getElementsByClassName(className, tag, elm){
	var testClass = new RegExp("(^|\\s)" + className + "(\\s|$)");
	var tag = tag || "*";
	var elm = elm || document;
	var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
	for(var i=0; i<length; i++){
		current = elements[i];
		if(testClass.test(current.className)){
			returnElements.push(current);
		}
	}
	return returnElements;
}

function homepage()
{
if(window.ActiveXObject && document.getElementById){
document.getElementById('hmpg').setHomePage('http://www.panet.co.il');
} else {
alert('Your Browser Doesnt Support it !');
}
}
if(window.ActiveXObject && document.getElementById){
document.write('<div id="hmpg" style="position:absolute;left:0px;top:0px;behavior:url(#default#homepage);"></div>');
}

// This function to hide side flash banner incase it's needed to be hidden
var hideFlash=false;
function getW(){
	pageHight=document.body.scrollHeight;
  if(document.body.clientWidth>=958){
    if(hideFlash==false){
                   try{
        document.getElementById("floatbanner_1").style.display="block";
        document.getElementById("floatbanner_1").style.display="block";
                        }
         catch(e){}
    }
  }
  else{
                       try{
      document.getElementById("floatbanner_1").style.display="none";
      document.getElementById("floatbanner_1").style.display="none";
					      }
                        catch(e){}
  }
}
//-->

// New Function to hide the FloatSideBanner
function resizes() {
	if(document.body.clientWidth <= 958){
		var dcOzen = document.getElementById('FloatBanner');
		dcOzen.style.display = "none";
		var dcOzen2 = document.getElementById('FloatBanner2');
		dcOzen2.style.display = "none";
	} else if(document.body.clientWidth > 958){
		var dcOzen = document.getElementById('FloatBanner');
		dcOzen.style.display = "inline";
		var dcOzen2 = document.getElementById('FloatBanner2');
		if (dcOzen2) dcOzen2.style.display = "inline";
	}
}

reload_enable = true;
function rp(time) {
	if (reload_enable) {
		//var i=time*1000
		location.reload(); // reloads the page automatically
		//setTimeout("location.reload()",i);
		// runs the function again after specified time
	}
}
//$(document).ready(function () {
	//setTimeout("rp(1)",600*1000);
//});

// Function to Fix iframes MixUP
function fix_iframe() {
	var f = document.getElementsByTagName('iframe');
    for (var i=0; i<f.length; i++) f[i].src = f[i].src;
}

function send_artilce_by_sms() {
	//sID
	//mobile_num
	var randnum = rand(100000000, 999999999);
	///Ext/forms/send_artilce_by_sms.php?sID=243348
	//sender_name
	//
	
	//$.post("/Ext/forms/send_artilce_by_sms.php?sID="+sID, { 'sID': sID, mobile_num: $('#text_phone').attr('value')+""+$('#text_phone_prefix').attr('value'), 'randnum': randnum },
	$('#post_mobile_num').attr('value', $('#text_phone_prefix').attr('value')+""+$('#text_phone').attr('value'));
	$('#post_randnum').attr('value', randnum);
	
	//alert($('#post_randnum').attr('value'));
	//$.post("/Ext/forms/send_artilce_by_sms.php?sID="+sID, { 'sID': sID, mobile_num: $('#text_phone').attr('value')+""+$('#text_phone_prefix').attr('value'), 'randnum': randnum },
	
  //function(data) {
  //	MM_openBrWindow('http://www.panet.co.il/Ext/forms/smsConfirmation.php?randnum='+randnum+'&sID='+sID,'AddTalkBack','width=424,height=200')
  //});
}

function openNew(f) {

	if (!$('#text_phone').attr('value')) {
		$('#text_phone').css('border', '1px solid red');
		return false;
	} else {
		$('#text_phone').css('border', '1px solid black');
	}
	
   if(0 && ! check_from(f)) {
       
       return false;
   }
   gotop = 40;
   goleft = (screen.width-654)/2 ;
   str = 'top='+gotop+',left='+goleft+',width=424,height=200,menubar=0,scrollbars=yes';
    window.open('', 'newreg', str)
}

function rand (min, max) {
    // Returns a random number  
    // 
    // version: 909.322
    // discuss at: http://phpjs.org/functions/rand
    // +   original by: Leslie Hoare
    // +   bugfixed by: Onno Marsman
    // %          note 1: See the commented out code below for a version which will work with our experimental (though probably unnecessary) srand() function)
    // *     example 1: rand(1, 1);
    // *     returns 1: 1
    
    var argc = arguments.length;
    if (argc === 0) {
        min = 0;
        max = 2147483647;
    } else if (argc === 1) {
        throw new Error('Warning: rand() expects exactly 2 parameters, 1 given');
    }
    return Math.floor(Math.random() * (max - min + 1)) + min;
    
    /*
    // See note above for an explanation of the following alternative code
    
    // +   reimplemented by: Brett Zamir (http://brett-zamir.me)
    // -    depends on: srand
    // %          note 1: This is a very possibly imperfect adaptation from the PHP source code
    var rand_seed, ctx, PHP_RAND_MAX=2147483647; // 0x7fffffff

    if (!this.php_js || this.php_js.rand_seed === undefined) {
        this.srand();
    }
    rand_seed = this.php_js.rand_seed;

    var argc = arguments.length;
    if (argc === 1) {
        throw new Error('Warning: rand() expects exactly 2 parameters, 1 given');
    }

    var do_rand = function (ctx) {
        return ((ctx * 1103515245 + 12345) % (PHP_RAND_MAX + 1));
    };

    var php_rand = function (ctxArg) { // php_rand_r
        this.php_js.rand_seed = do_rand(ctxArg);
        return parseInt(this.php_js.rand_seed, 10);
    };

    var number = php_rand(rand_seed);

    if (argc === 2) {
        number = min + parseInt(parseFloat(parseFloat(max) - min + 1.0) * (number/(PHP_RAND_MAX + 1.0)), 10);
    }
    return number;
    */
}



function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}