
/// DEFAULT JS SCRIPT

w33c = (document.getElementById)? true:false;
if (w33c) {
	nsb4 = false;
	ieb4 = false;
}
else if (!w33c) {
	nsb4 = (document.layers)? true:false;
	ieb4 = (document.all)? true:false;
}


if (w33c || ieb4 || nsb4) 	browserOK = true;

if (navigator.userAgent.indexOf("Firefox")!=-1)
	firefox = 1;
else
	firefox = 0;
	
if(location.hostname == "localhost")
	domain = 'localhost/www.bulk-sms.be/';
else
	domain = location.hostname+"/";

domain =  "http://"+domain;

function con(msg) {
	
	if(!msg)
		msg = "Let op: Weet u dit zeker ?";
        
	if(!confirm("Verwijderen?"))
		return false;
	
	return true;
}

function loadPopup(id) {
		
	if($('popup').visible())
		Effect.Fade('popup',{duration:0.2, queue:'front'});
		
	width = $(id).getStyle('width');
	
	$('popup').update($(id).innerHTML);
	$('popup').insert({bottom: '<div id="clear"></div><div class="close"><a href="#" onclick="Effect.BlindUp(\'popup\', {duration:0.3});">Sluit venster</a></div>'});
	Effect.Appear($('popup'), {queue:'end', duration: 0.5 });
	
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}


function doCheck() {
	
	Nifty('h1.round','small');
	Nifty('div.round','small');
	Nifty('div.roundT','normal');
	Nifty('div.topCorners','normal tr tl');
	Nifty('div.bottomCorners','normal bl br');
	Nifty('div.roundR','big bl tr');
	
	Nifty('li.round','normal');


}

function showDiv(div) {
	new Effect.Appear('overlay2', { duration: 0.5, from: 0.0, to: 0.8 });
	var arrayPageSize = getPageSize();
	$("overlay2").setStyle({ width: arrayPageSize[0] });
	$("overlay2").setStyle( { height: arrayPageSize[1] });
	Effect.Grow(div,{duration: 0.3 } );
	new Draggable(div);
}

function closeDiv(div) {
		new Effect.Fade('overlay2', {duration: 0.2 });
		Effect.Fade(div,{duration: 0.2 });
		$(div).update('');
}


function counter() {
	
	var nbcar = 0;
	var content;
	var s;
	var countE= 0;
	var msglen = 160;
	var msg = $('send_content');
	
	nbcar = $('send_content').value.length;
	content = $('send_content').value;
	
	arr = new Array();
	arr[0] ="[";
	arr[1] = "\\";
	
	arr[2] = "]";
	arr[3] = "^";
	arr[4] = "{";
	arr[5] = "|";
	arr[6] = "}";
	arr[7] = "~";
	arr[8] = "€";
	arr[9] = "/";
	
	
	
	for (var i = 0; i < content.length; i++) {
		if ((content.charCodeAt(i) == 10) ) {
			msglen--;
			countE++;
		}
	}
	
	
	for(i=0;i<=160;i++) {

		arr.each(function(item) {
		  if(content.charAt(i)==item ) {
		  	msglen--;
		  }
		});
		
	}
	
	if(!firefox) {
		msglen = msglen+countE;
	}
	
	if (nbcar > msglen ) {
		msg.value = $('send_content').value.substring(0,msglen);
		valcar = 0;
	} 
	else  {
		valcar = msglen - nbcar;
		$('char_left').update(valcar);
	}
	
	
	 
	 
	 
}


function selectUser(number) {
	
	c = $F('to');
	
	if(c)
		c = c+";"+number;
	else
		c = number;

	$('to').value = c;
		
	
}
