var _THIS_DOMAIN_NAME = "http://www.promoart.com";

 function printLink(strArr){
     document.write('<a class="text" href="mailto:&#'+strArr.join(';&#')+';?subject=PLENTYOFSNOW.COM" rel="nofollow">&#'+strArr.join(';&#')+'</a>');
 }

function get_URLKEY(src,dst) { 
	sr = _LATIN_SYMBOLS;
	rp = _LATIN_SYNONIMS;
	
	news = new String(src);
	newstr = new String();
	news = news.toLowerCase();							// convert string to lover case 
	
	for(i=0;i<news.length;i++) {
		add_=true; 
		for (j=0;j<sr.length;j++) if (news.charAt(i) == sr[j]) {newstr+=rp[j]; add_=false; j=sr.length;}
		if (add_) newstr+=news.charAt(i);
	}

	newstr=newstr.replace(/[^a-zA-Z0-9\-\s]/gi,"");		//delete all special characters 
	newstr=newstr.replace(/[\s]+/g," ");				//replace consecutive spaces by one
	newstr=newstr.replace(/[\s]+/gi, "-");				//replace all spaces by dash 
	newstr=newstr.replace(/[^a-zA-Z0-9]$/gi,"");		//delete all special characters at the end of string
	newstr=newstr.replace(/^[^a-zA-Z0-9]/gi,"");		//delete all special characters at the beginning of string
	
	dst.value=newstr; 
}

function GetObject(obj_id) {
    return document.getElementById(obj_id);
}

 
function Show_Hide_Element(element_id) {
   el=document.getElementById(element_id);
   if (el.style.display=='') el.style.display='none';
   else el.style.display='';
}

function setVis(element_id,visible) {			// Show or Hide element
	el=document.getElementById(element_id);
	if(visible == null) visible = el.style.display
	el.style.display = (visible == '') ? 'none' : '';
}

function intoVal(value, mode) {
	mode = (mode != null) ? mode : '';
	switch(mode) {
		case "float": {
			value = ((value + '').replace(",",".")).match(/\-*\d+[.]?\d*/);
			if(value == null) return 0;
			 else return parseFloat(value);
			break;
		}
		default: {				// return integer as default
			value = (value + '').match(/\d+/);
			if(value == null) return 0;
			 else return parseInt(value);
			break;
		}
	} 
}

function in_array(the_needle, the_haystack){
	var the_hay = the_haystack.toString();
	if(the_hay == '') {return false;}
	var the_pattern = new RegExp(the_needle, 'g');
	var matched = the_pattern.test(the_haystack);
	return matched;
}

function resetValues(form,excludes) {
	if(excludes == null) excludes = '';
	for(i=0;i < form.elements.length; i++) {
		el = form.elements[i];
		if(!(el.id != '' && in_array(el.id,excludes)) && !(el.name != '' && in_array(el.name,excludes))) {
			if(form.elements[i].type.match(/^select/)) form.elements[i].selectedIndex = 0;
			 else form.elements[i].value = '';
		}
	}
	return true;
}

function sort_list(type) {
	document.sort_by_form._sort_type.value = type;
	document.sort_by_form.submit();
}

function show_model(id,mode) {
	resize = 'no';
	w = 150; h = 185;
	w_big = 600; h_big = 635;
	if(mode == "full") {
		mode = "&mode=" + mode;
		w = w_big; h = h_big;
		resize = 'yes';
	}
	var postop =(screen.height /2)-(h/ 2);
	var posleft =(screen.width /2)-(w/ 2);
	window.open(_THIS_DOMAIN_NAME + '/admin/photos/show_model/?photo_id='+id+mode, '',
				'width=' + w + ',height=' + h + ',left='+posleft+',top=' + postop +
				',scrollbars=no,menubar=no,resizable=' + resize + ',location=no,status=no'
				);
}

function SelectSelect(SelList) {	// SELECT ALL ITEMS IN THE MULTI LIST SELECT OBJECT
	SelList=document.getElementById(SelList);
	if (SelList && SelList.length > 0)
    for (x=0; x < SelList.length; x++) { 
	  if (SelList.options[x]) SelList.options[x].selected=true;
    }
}

function load_script(module) // LOAD SCIRPT
{
   var currentTime = new Date();
   document.getElementById('scr').innerHTML='&nbsp;<script></' + 'script>';
   var script = document.getElementById('scr').getElementsByTagName("script")[0];
   href=module+'?tm='+currentTime.getTime();     
   if (script.setAttribute) script.setAttribute('src', href); else script.src = href;
}
 function printLink(strArr){
     document.write('<a class="text" href="mailto:&#'+strArr.join(';&#')+';?subject=" rel="nofollow">&#'+strArr.join(';&#')+'</a>');
}