function loadjscssfile(filename, filetype){
 if (filetype=="js"){ //if filename is a external JavaScript file
  var fileref=document.createElement('script')
  fileref.setAttribute("type","text/javascript")
  fileref.setAttribute("src", filename)
 }
 else if (filetype=="css"){ //if filename is an external CSS file
  var fileref=document.createElement("link")
  fileref.setAttribute("rel", "stylesheet")
  fileref.setAttribute("type", "text/css")
  fileref.setAttribute("href", filename)
 }
 if (typeof fileref!="undefined")
  document.getElementsByTagName("head")[0].appendChild(fileref)
}

//loadjscssfile("http://integration.ironhorseinteractive.com/scripts/jquery-1.2.5.js", "js");
//loadjscssfile("http://integration.ironhorseinteractive.com/scripts/1105_sprint_category.js", "js") //dynamically load and add this .js file

function getURLParam(strParamName) {
	var strReturn = "";
	  var strHref = window.location.href;
	  var bFound=false;
	  
	  var cmpstring = strParamName + "=";
	  var cmplen = cmpstring.length;

	  if ( strHref.indexOf("?") > -1 ){
	    var strQueryString = strHref.substr(strHref.indexOf("?")+1);
	    var aQueryString = strQueryString.split("&");
	    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
	      if (aQueryString[iParam].substr(0,cmplen)==cmpstring){
	        var aParam = aQueryString[iParam].split("=");
	        strReturn = aParam[1];
	        bFound=true;
	        break;
	      }
	      
	    }
	  }
	  if (bFound==false) return null;
	  return strReturn;
}	



{
    function ihvGetOldScriptSrc(){
        var s = document.getElementById('ihvscript');
        var src = s.getAttribute('src');
        if (src != null && typeof(src) == 'string') {
            if (typeof(s.id) == 'undefined' || s.id != 'ihv-auto') 
            {
                return s;
            }
        }
        return null;
    }


	function stringFilter (s) {
		filteredValues = "1234567890";     // Characters stripped out
		var i;
		var returnString = "";
		for (i = 0; i < s.length; i++) {  // Search through string and append to unfiltered values to returnString.
			var c = s.charAt(i);
			if (filteredValues.indexOf(c) != -1) returnString += c;
		}
		return returnString;
	}
    
    
    var old = ihvGetOldScriptSrc();
    if (old != null) {
    
        var oSpan = document.createElement("span");

		var theURL = 'http://sprint.ihvweb3.com/';
		
		var cat = getURLParam('category');
		
		var c = '';
		if(document.getElementById && document.getElementById('ihvscript')) {
			var s = document.getElementById('ihvscript');
			var cn = s.className;
			c = stringFilter(cn);
			if(c) {
				// strip any quotes that happen to be there
				c = c.replace('"', '');
				c = c.replace('&#148;', '');
				c = c.replace('”', 'a');
				c = c.replace('&rdquo;', '');
				c = c.replace('&ldquo;', '');
				
				if(cat && (cat == 1 || cat == 2 | cat == 3)) {
					theURL += "index.php/download/index/"+c+"/"+cat;
				} else {
					theURL += "index.php/landing/index/"+c;
				}
			}
		}
		
			
		
//		theURL = 'http://moblin-contest.org';
		//theURL = 'http://sprint.ihvweb.com';
        oSpan.innerHTML = ''+
  	'<iframe src="'+theURL+'" frameborder="0" width="920" scrolling="no" height="675">'+
	'</iframe>';
        old.parentNode.insertBefore(oSpan, old);
        
    }
}






/*
{
    function ihvGetOldScriptSrc(){
        var s = document.getElementById('ihvscript');
        var src = s.getAttribute('src');
        if (src != null && typeof(src) == 'string') {
            if (typeof(s.id) == 'undefined' || s.id != 'ihv-auto') 
            {
                return s;
            }
        }
        return null;
    }


	function stringFilter (s) {
		filteredValues = "1234567890";     // Characters stripped out
		var i;
		var returnString = "";
		for (i = 0; i < s.length; i++) {  // Search through string and append to unfiltered values to returnString.
			var c = s.charAt(i);
			if (filteredValues.indexOf(c) != -1) returnString += c;
		}
		return returnString;
	}
    
    
    var old = ihvGetOldScriptSrc();
    if (old != null) {
    
        var oSpan = document.createElement("span");

		var theURL = 'http://sprint.ihvweb.com/';
		
		var c = '';
		if(document.getElementById && document.getElementById('ihvscript')) {
			var s = document.getElementById('ihvscript');
			var cn = s.className;
			c = stringFilter(cn);
			if(c) {
				// strip any quotes that happen to be there
				c = c.replace('"', '');
				c = c.replace('&#148;', '');
				c = c.replace('”', 'a');
				c = c.replace('&rdquo;', '');
				c = c.replace('&ldquo;', '');
				
				theURL += "index.php/landing/index/"+c;
			}
		}
		
//		theURL = 'http://moblin-contest.org';
		//theURL = 'http://sprint.ihvweb.com';
        oSpan.innerHTML = ''+
  	'<iframe src="'+theURL+'" frameborder="0" width="920" scrolling="no" height="675">'+
	'</iframe>';
        old.parentNode.insertBefore(oSpan, old);
        
    }
}
*/