//-------------------------------------------------------------
function set_errorfiled(name,message){
	var el = document.getElementById(name);	
	el.className = el.className+' formError';
	el.innerHTML = el.innerHTML+'<br><font color=red>'+message+'</font>';	
}
//-------------------------------------------------------------
function sh(id,lnk){
	var el = document.getElementById(id);
	if(el.style.display=='none'){
		  el.style.display= 'block';
		  SetCookie('vmemo_'+id,'show','99999999');
		  lnk.innerHTML = 'Hide additional features';
	}
	else{
		 el.style.display= 'none';
		 SetCookie('vmemo_'+id,'hide','99999999');
		 lnk.innerHTML = 'Show additional features';
	}
	return false;
}
//-------------------------------------------------------------
function SetCookie(sName, sValue,sTime)
{
    document.cookie = sName + "=" + escape(sValue) + "; path=/";
}
//-------------------------------------------------------------
function csubmit(name){

	var f = document.forms[name];
	var len = f.elements.length;
	var checked = 0;
	for( i=0 ; i<len ; i++){
		if (f.elements[i].name=='plans[]'){
			if(f.elements[i].checked) checked++;
		}
	}	
	if(checked <= 1){
		alert('Please select at least two plans to be compared');
		return false;
	}
	if(f){
		f.submit();
	}
	return false;
}
//-------------------------------------------------------------
function d(el){
	return document.getElementById(el);
}
var current_image_picker_id ='';
function open_image_picker(id){
	this.current_image_picker_id = id;
	$('image_picker')
	ModalDialog.init();
	ModalDialog.setTitle('Pick an image:');
	ModalDialog.setHTMLElement($('image_picker'));
	ModalDialog.setWidth(800);
	ModalDialog.setHeight(500);
	ModalDialog.open();
}
function set_picked_image(image_id,image_extension){
	$(current_image_picker_id+'_img').src = 'upload/'+image_id+'_th.'+image_extension;
	$(current_image_picker_id+'_text').value = image_id;
	ModalDialog.close();
}
function massReplace(token, findThis, replaceWithThis) {
	replaceHash = token.toString();
	thisIndex = replaceHash.indexOf(findThis);


	while(thisIndex !=- 1) {
		replaceHash = replaceHash.replace(findThis, replaceWithThis);
		thisIndex = replaceHash.indexOf(findThis);
	}

	return replaceHash;
}
function OpenNewWindow(bigurl, width, height)
{
    var newWindow = window.open("", "pictureViewer", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=yes,fullscreen=0,width="+width+",height="+height);
    newWindow.document.writeln("<html><head><title>www.photoicon.com</title></head>");
    newWindow.document.writeln("<body style='margin: 0px; left: 0px; top: 0px; padding: 0px;'>");
    newWindow.document.writeln("<img src='" + bigurl + "' alt='' id='bigImage' style='margin: 0px;'><br>");
    newWindow.document.writeln("</body></html>");
    newWindow.document.close();
}
