//alert("2");
var str_link=new String(document.URL);
str_link=str_link.split(".com");

var siteurl = str_link[0]+'.com/';

//alert(siteurl);
var newXmlHttp;
var newxmlHttp5;
var divId="";
var txt='';
function ajaxLink(url,did)
{
	divId=did;
	newXmlHttp=GetnewXmlHttpObject();
	
	document.getElementById(divId).innerHTML='<div align="center"><img src="http://www.theindiatube.com/images/load2.gif" border="0" /></div>'+document.getElementById(divId).innerHTML;
	
	if (newXmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	if(url.indexOf("?")!=-1)
	url=siteurl+url+"&stid="+Math.random();
	else
	url=siteurl+url+"?stid="+Math.random();
	
	//alert(url);
	newXmlHttp.onreadystatechange=newStateChanged ;
	newXmlHttp.open("GET",url,true);
	newXmlHttp.send(null);
} 


function ajax_Link(url,did)
{
	divId=did;
	newXmlHttp=GetnewXmlHttpObject();
	
	//document.getElementById(divId).innerHTML='<div align="center"><img src="images/load2.gif" border="0" /></div>'+document.getElementById(divId).innerHTML;
	
	if (newXmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	if(url.indexOf("?")!=-1)
	url=siteurl+url+"&stid="+Math.random();
	else
	url=siteurl+url+"?stid="+Math.random();
	
	//alert(url);
	newXmlHttp.onreadystatechange=newStateChanged ;
	newXmlHttp.open("GET",url,true);
	newXmlHttp.send(null);
} 

function replacediv(type,id,username)
{
	divId="replacediv";
	newXmlHttp=GetnewXmlHttpObject();
	
	if (newXmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	url="photoembedreplace.php?type="+type+"&id="+id+"&username="+username;
	if(url.indexOf("?")!=-1)
	url=siteurl+url+"&stid="+Math.random();
	else
	url=siteurl+url+"?stid="+Math.random();
	
	//alert(url);
	newXmlHttp.onreadystatechange=newStateChanged ;
	newXmlHttp.open("GET",url,true);
	newXmlHttp.send(null);
	
}

function newStateChanged()
{ 
	if (newXmlHttp.readyState==4 || newXmlHttp.readyState=="complete")
	{ 
	 document.getElementById(divId).innerHTML=newXmlHttp.responseText ;	
	}
} 


//////////////////////////////Start show two ajaxAlert
var divId1;
var divId2;
function showTwo(url1,div1,url2,div2)
{
	 divId1=div1;
	 divId2=div2;	
	newxmlHttp=GetnewXmlHttpObject();
	newxmlHttp5=GetnewXmlHttpObject();
	if (newxmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	if(url1.indexOf("?")!=-1)
	url1=siteurl+url1+"&sid="+Math.random();
	else
	url1=siteurl+url1+"?sid="+Math.random();
	
	if(url2.indexOf("?")!=-1)
	url2=siteurl+url2+"&sid="+Math.random();
	else
	url2=siteurl+url2+"?sid="+Math.random();
	newxmlHttp.onreadystatechange=stateChanged4 ;
	newxmlHttp.open("GET",url1,true);
	newxmlHttp.send(null);
	newxmlHttp5.onreadystatechange=stateChanged5 ;
	newxmlHttp5.open("GET",url2,true);
	newxmlHttp5.send(null);
} 
function stateChanged4()
{ 
	if (newxmlHttp.readyState==4 || newxmlHttp.readyState=="complete")
	{ 	// alert(divId1);
		//alert(newxmlHttp.responseText);		
		document.getElementById(divId1).innerHTML=newxmlHttp.responseText ;
	}
} 
function stateChanged5()
{ 
	if (newxmlHttp5.readyState==4 || newxmlHttp5.readyState=="complete")
	{ 		// alert(divId2);
		//alert(newxmlHttp5.responseText);		
		document.getElementById(divId2).innerHTML=newxmlHttp5.responseText ;					
	}
} 
//////////////////////////////END show two
function GetnewXmlHttpObject()
{ 
	var objnewXmlHttp=null;
	if (window.XMLHttpRequest)
	{
		objnewXmlHttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		objnewXmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return objnewXmlHttp;
} 



function strstr (haystack, needle, bool) {
    // Finds first occurrence of a string within another  
    // 
    // version: 909.322
    // discuss at: http://phpjs.org/functions/strstr    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Onno Marsman
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: strstr('Kevin van Zonneveld', 'van');
    // *     returns 1: 'van Zonneveld'    // *     example 2: strstr('Kevin van Zonneveld', 'van', true);
    // *     returns 2: 'Kevin '
    // *     example 3: strstr('name@example.com', '@');
    // *     returns 3: '@example.com'
    // *     example 4: strstr('name@example.com', '@', true);    // *     returns 4: 'name'
    var pos = 0;
    
    haystack += '';
    pos = haystack.indexOf( needle );    if (pos == -1) {
        return false;
    } else{
        if (bool){
            return haystack.substr( 0, pos );        } else{
            return haystack.slice( pos );
        }
    }
}


function strip_tags (str, allowed_tags) {
    // Strips HTML and PHP tags from a string  
    // 
    // version: 909.322
    // discuss at: http://phpjs.org/functions/strip_tags    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Luke Godfrey
    // +      input by: Pul
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Onno Marsman    // +      input by: Alex
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: Marc Palau
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: Brett Zamir (http://brett-zamir.me)    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Eric Nagel
    // +      input by: Bobby Drake
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Tomasz Wesolowski    // *     example 1: strip_tags('<p>Kevin</p> <b>van</b> <i>Zonneveld</i>', '<i><b>');
    // *     returns 1: 'Kevin <b>van</b> <i>Zonneveld</i>'
    // *     example 2: strip_tags('<p>Kevin <img src="someimage.png" onmouseover="someFunction()">van <i>Zonneveld</i></p>', '<p>');
    // *     returns 2: '<p>Kevin van Zonneveld</p>'
    // *     example 3: strip_tags("<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>", "<a>");    // *     returns 3: '<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>'
    // *     example 4: strip_tags('1 < 5 5 > 1');
    // *     returns 4: '1 < 5 5 > 1'
    var key = '', allowed = false;
    var matches = [];    var allowed_array = [];
    var allowed_tag = '';
    var i = 0;
    var k = '';
    var html = ''; 
    var replacer = function (search, replace, str) {
        return str.split(search).join(replace);
    };
     // Build allowes tags associative array
    if (allowed_tags) {
        allowed_array = allowed_tags.match(/([a-zA-Z0-9]+)/gi);
    }
     str += '';
 
    // Match tags
    matches = str.match(/(<\/?[\S][^>]*>)/gi);
     // Go through all HTML tags
    for (key in matches) {
        if (isNaN(key)) {
            // IE7 Hack
            continue;        }
 
        // Save HTML tag
        html = matches[key].toString();
         // Is tag not in allowed list? Remove from str!
        allowed = false;
 
        // Go through all allowed tags
        for (k in allowed_array) {            // Init
            allowed_tag = allowed_array[k];
            i = -1;
 
            if (i != 0) { i = html.toLowerCase().indexOf('<'+allowed_tag+'>');}            if (i != 0) { i = html.toLowerCase().indexOf('<'+allowed_tag+' ');}
            if (i != 0) { i = html.toLowerCase().indexOf('</'+allowed_tag)   ;}
 
            // Determine
            if (i == 0) {                allowed = true;
                break;
            }
        }
         if (!allowed) {
            str = replacer(html, "", str); // Custom replace. No regexing
        }
    }
     return str;
}

