function isString(){
	if (typeof(arguments[0]) == 'string'){return true;}
	if(typeof(arguments[0]) == 'object'){
		var criterion = arguments[0].constructor.toString().match(/string/i); 
		return (criterion != null);
	}
	return false;
}

function get_parent(obj,findTag){//,debug
	if(!findTag || !basic_check(findTag)){findTag='*';}
//if(!debug){debug=false;}
	var count=0;
	var foundObj=false;
	var limit=10;
	var parentObj=false;
	do{
		if(!parentObj){parentObj=obj;}
		parentObj=parentObj.parentNode;
		tmpName=parentObj.tagName;
		if(tmpName && findTag=='*'){findTag=tmpName;}
//if(debug==true){alert('findTag: ' + findTag +' |||| '+tmpName);}
		count++;
		if(tmpName.toLowerCase()=='html'){break;}
	}while(tmpName.toLowerCase()!=findTag.toLowerCase() && count<=limit)// && count<=100
	if(tmpName.toLowerCase()==findTag.toLowerCase()){foundObj=parentObj;}
	//if(count==limit){alert('xxx');}
	return foundObj;
}
function basic_check(stringIn){
	if(typeof(stringIn)=='string'){
		tmp=stringIn.trim();
		if(tmp.length>0){
			return true;
		}else{
			return false;}
	}else{
		return false;}
}
function check_strip_last(stringIn,checkFor){
	output="";
	if(!(stringIn.indexOf(checkFor)==-1)){//found
		startPoint=stringIn.length-checkFor.length;
		tmp=stringIn.substr(startPoint,checkFor.length);
		if(tmp==checkFor){
			output=stringIn.substr(0,(stringIn.length-checkFor.length));}
		else{
			output=stringIn;}		
		return output;
	}else{
		return stringIn;}
}
function check_strip_first(stringIn,checkFor){
	output="";
	if(!(stringIn.indexOf(checkFor)==-1)){//found
		startPoint=stringIn.length-checkFor.length;
		tmp=stringIn.substr(0,checkFor.length);
		if(tmp==checkFor){
			output=stringIn.substr(checkFor.length,stringIn.length);}
		else{
			output=stringIn;}	
		return output;
	}else{
		return stringIn;}	
}
function popup(target,width,height,mode) {
	default_width=600;
	default_height=400;
	if(!width){width=default_width;}
	else{
		width=parseInt(width);}
	if(!height){height=default_height;}
	else{
		height=parseInt(height);}
	if(width<1){width=default_width;}
	if(height<1){height=default_height;}
	link_loc=target.href;
	ext=get_file_extension(link_loc);
	ext=ext.toLowerCase();
	var pop_str='';
	if(mode=='new_win'){pop_str="width="+width+",height="+height+",toolbar=yes,menubar=yes,location=yes,scrollbars=yes,resizable=yes";}
	else{pop_str="width="+width+",height="+height+",toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes";}
	if(ext=='.jpg' || ext=='.jpeg' || ext=='.jpe' || ext=='.gif' || ext=='.png'){
		popwin = window.open("", new Date().getTime(), pop_str);
		popwin.document.open();
		popwin.document.write('<html><body style="margin:0px;padding:0px;">'); 
		popwin.document.write('<img src="'+link_loc+'"></body></html>'); 
		popwin.document.close();
		popwin.focus();
	}else{
		popwin = window.open(link_loc, new Date().getTime(), pop_str);}
	popwin.focus();
    return false;
}
function get_file_extension(stringIn){ 
	var filename = stringIn; 
	if( filename.length == 0 ) return "";
	var dot = filename.lastIndexOf("."); 
	if( dot == -1 ) return ""; 
	var extension = filename.substr(dot,filename.length); 
	return extension; 
} 
function switchFormErr(tableOBJ,tableClass,divOBJ,divClass){
	if(typeof(tableOBJ)=='object' && basic_check(tableOBJ.tagName)){
		tableOBJ.className=tableClass;
	}else if(typeof(tableOBJ)=='string'){
		if(basic_check(document.getElementById(tableOBJ).tagName)){
			document.getElementById(tableOBJ).className=tableClass;}
	}
	if(typeof(divOBJ)=='object' && basic_check(divOBJ.tagName)){
		divOBJ.className=divClass;
	}else if(typeof(divOBJ)=='string'){
		if(basic_check(document.getElementById(divOBJ).tagName)){
			document.getElementById(divOBJ).className=divClass;}
	}
}
function getStyle(el,styleProp){
	var x = document.getElementById(el);
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}
function getStyle_bd(el,styleProp){
	var x = el;
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}
Array.match = function(array){
	if(array.constructor==Array){
		var find_obj=new Object;
		var dup_found=false;
		for(var m_key in array){
			if(!find_obj[array[m_key]]){
				find_obj[array[m_key]]=1;
			}else{
				find_obj[array[m_key]]++;
				dup_found=true;
				break;
			}
		}
		return dup_found;
	}else{
		return false;
	}
};
function in_array (needle, haystack, argStrict) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: vlado houba
    // +   input by: Billy
    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)

    var key = '', strict = !!argStrict;
    if (strict) {
        for (key in haystack) {
            if (haystack[key] === needle) {
                return true;
            }
        }
    } else {
        for (key in haystack) {
            if (haystack[key] == needle) {
                return true;
            }
        }
    }
    return false;
}

function MM_preloadImages() { //v3.0
	var d=document;
	if(d.images){
		if(!d.MM_p){d.MM_p=new Array();}
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
		for(i=0; i<a.length; i++){
			if (a[i].indexOf("#")!=0){
				d.MM_p[j]=new Image;
				d.MM_p[j++].src=a[i];
			}
		}
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function getXMLValue(nodeIn){
	if(typeof(nodeIn.data)!='undefined'){
		output=nodeIn.data;}
	else if(typeof(nodeIn.textContent)!='undefined' && typeof(nodeIn.text)=='undefined'){
		output=nodeIn.textContent;}
	else{
		output=nodeIn.text;}
	return output;
}
function showChip(numIn){
	if($('#container-'+numIn).length>0){
		$('.colours-container').css('display','none');
		$('.colours-container#container-'+numIn).css('display','block');
	}
}
$(document).ready(function() {
	//$('body').supersleight();
});
