function vote_activity(parent_id, parent_type , user_id ,response){ 
  url = base_url+'/ajax/save_activity_response.php';
  $.get(
      url,
      {
        'parent_id': parent_id,
        'parent_type': parent_type,
        'user_id': user_id,
        'response':response 
      },
      function(htmlData) { 
        var inner_data = htmlData.split('!@&&');
        document.getElementById('like_'+parent_id).innerHTML = '';
        document.getElementById('like_users_'+parent_id).innerHTML = '';
        document.getElementById('like_'+parent_id).innerHTML = inner_data[0];
        if (inner_data[1]) { 
          document.getElementById('ac_'+parent_id).style.display = 'block';
          document.getElementById('like_users_'+parent_id).innerHTML = inner_data[1];
        } else { 
           document.getElementById('ac_'+parent_id).style.display = 'none';
        }
      }
  );
}

function activity_response_popup(object, parent_id, parent_type){
   try {
  x = findPosX(object);
  y = findPosY(object);
  document.getElementById('common_friend_body').style.display = 'block';
  var obj2 = document.getElementById('common_friend_text');
  $.get(
     base_url + "/ajax/voted_users.php",
     {
      'parent_id': parent_id,
      'parent_type':parent_type
     },
     function(htmlData) {
        $('#common_friend_text').html(htmlData);
     }
   );
    document.getElementById('common_friend_body').style.left = 250+scrollX()+'px';
    document.getElementById('common_friend_body').style.top = 50+scrollY()+'px';
    document.getElementById('common_friend_iframe').style.display = 'block';
     document.getElementById('common_friend_iframe').style.left = 270+scrollX()+'px';
     document.getElementById('common_friend_iframe').style.top = 54+scrollY()+'px';
    } catch (e) { 
    }
}

function save_wall_comment(frm){
  if(trim(frm.comm.value) == '') {
    document.getElementById('em_wall_comm_'+frm.wid.value).style.display = 'none';
    document.getElementById('em_show_comm_'+frm.wid.value).style.display = 'block';
  } else {
    url = base_url+'/ajax/save_wall_comment.php';
    var params = {};
      params['wall_id'] = frm.wid.value;
      params['owner_id'] = frm.owner_id.value;
      params['comment'] = frm.comm.value;
      if(frm.wc_typ.value == 'wa') {
        params['wc_typ'] = frm.wc_typ.value;
      }
    $.post(
        url,
      params,
        function(htmlData) {
          document.getElementById('wc_div_'+params['wall_id']).innerHTML = htmlData;
          document.getElementById('wall_text_area_'+ params['wall_id']).value = '';
        }
    );
  }
  return false;
}

function show_wall_comm_form(show,wall_id) {
if(show) {
  document.getElementById('em_wall_comm_'+wall_id).style.display = 'block';
  document.getElementById('em_show_comm_'+wall_id).style.display = 'none';
  document.getElementById('wall_text_area_'+wall_id).focus();
} else {
  if(trim(document.getElementById('wall_text_area_'+wall_id).value) == '') {
    document.getElementById('em_wall_comm_'+wall_id).style.display = 'none';
    document.getElementById('em_show_comm_'+wall_id).style.display = 'block';
  }
}
}

function wall_filter(filter_type, wuid,tab_more) {
  url = base_url+'/ajax/wall_filter.php';
  if(tab_more == 'more') {
    var page = document.getElementById('page_id').value;
  } else {
    var page = 0;
  }
if(tab_more == 'more') {
  $('#more_'+page).html('<div style= "width:100%;text-align:center;float:left;"><br><img src="'+skin_url+'/images/loadingAnimation.gif" alt = "loading.." /></div>');
} else {
   $('#wall_feed_id').html('<div style= "width:100%;text-align:center;float:left;"><br><img src="'+skin_url+'/images/loadingAnimation.gif" alt = "loading.." /></div>');
}
  $.get(
      url,
      {
        'filter_type': filter_type,
        'wuid': wuid,
        'page':page,
        'tab_more':tab_more
      },
      function(htmlData) {
        if(tab_more == 'more') {
          document.getElementById('more_'+page).innerHTML = htmlData;
        } else {  
          document.getElementById('wall_feed_id').innerHTML = htmlData;
          change_filter_selection(filter_type);
        }
      }
  );
}

function change_filter_selection(filter_type) {
filter_array = new Array('all','status','photos','videos', 'groups','blogs','fan_clubs','links')
 for ( var i = 0; i < filter_array.length; i++ ) {
  if(filter_type == filter_array[i]) {
     document.getElementById('filter_'+filter_array[i]).className = 'selectedfilter'
  } else {
    document.getElementById('filter_'+filter_array[i]).className = ' '
  }
 }
}

function blank_status_field(show,msg) {
if(show) {
  if(document.getElementById('status_message_id').value == msg) {
    document.getElementById('status_message_id').value = '';
  }
} else {
  if(trim(document.getElementById('status_message_id').value) == "") {
    document.getElementById('status_message_id').value = msg
  }
}
}

function post_status_mesg(msg) {
if( document.getElementById('status_content_type')) {
 var cont_typ = document.getElementById('status_content_type').value
}
if(cont_typ == 'msg') {
  if(trim(document.getElementById('status_message_id').value) == "") {
      //alert("Please write something to post message")
      return false;
  } else if(trim(document.getElementById('status_message_id').value) == msg) {
    //alert("Please write something to post message")
    return false;
  }
} else {
  if(cont_typ == 'pics') {
    if(trim(document.getElementById('SourceFile_0').value) == "") {
      //alert("Please write something to post message")
      return false;
    }
  }
  if(trim(document.getElementById('status_message_id').value) == msg) {
    document.getElementById('status_message_id').value = '';
  }
  
}
  return true;
}
function upcoming_birthdays (uid,duration) {
if(duration == 'w') {
  document.getElementById('weak_birthday').innerHTML ='| '+__("This week")
  document.getElementById('today_birthday').innerHTML = '<a href="javascript:void(0);" onclick="upcoming_birthdays('+uid+',\'t\');" >'+__("Today")+'</a>';
} else {
   document.getElementById('weak_birthday').innerHTML ='| <a href="javascript:void(0);" onclick="upcoming_birthdays('+uid+',\'w\');" >'+__("This week")+'</a>';
  document.getElementById('today_birthday').innerHTML = __("Today");
}
  url = base_url+'/ajax/upcoming_birthdays.php';
  $.get(
      url,
      {
        'uid': uid,
        'duration':duration
      },
      function(htmlData) { 
        document.getElementById('brthUsrs').innerHTML = htmlData;
      }
  );
}
function wall_main_tab(type, uid) {
   $('#tab_id').html('<img src="'+skin_url+'/images/loadingAnimation.gif" alt = "loading.." />');
  url = base_url+'/ajax/view_profile.php';
  $.get(
      url,
      {
        'type': type,
        'uid': uid
      },
      function(htmlData) {
        if ( type == 'profile') {
          document.getElementById('profile_link').className = 'actives';
          document.getElementById('update_link').className = '';
        } else {
          document.getElementById('profile_link').className = '';
          document.getElementById('update_link').className = 'actives';
        }
        document.getElementById('tab_id').innerHTML = htmlData;
// pageScroll('contact');
      }
  );
}

function delete_wall_comment(id,typ){
  url = base_url+'/ajax/delete_wall_comment.php';
  var params = {};
  if(typ){
    params['typ'] = typ;
  }
  params['comment_id'] = id;
  $.post(
      url,
     params,
      function(htmlData) {
        if(htmlData == 'deleted' && params['typ'] == 'wall_comment') {
          document.getElementById('wall_comment_'+id).innerHTML = '';
        } else if(htmlData == 'deleted' && params['typ'] == 'wall_update') {
          document.getElementById('wall_update_cont_'+id).innerHTML = '';
        }
      }
  );
}

function all_fan_popup(object,parent_id){
   try {
  document.getElementById('common_friend_body').style.display = 'block';
  var obj2 = document.getElementById('common_friend_text');
  $.get(
     base_url + "/ajax/get_all_fans.php",
     {
      'parent_id': parent_id
     },
     function(htmlData) {
        $('#common_friend_text').html(htmlData);
     }
   );
    document.getElementById('common_friend_body').style.left = 250+scrollX()+'px';
    document.getElementById('common_friend_body').style.top = 50+scrollY()+'px';
    document.getElementById('common_friend_iframe').style.display = 'block';
     document.getElementById('common_friend_iframe').style.left = 270+scrollX()+'px';
     document.getElementById('common_friend_iframe').style.top = 54+scrollY()+'px';
    } catch (e) { 
    }
}

function track_url_onspace(e) {
 var code = find_key(e);
// alert(code);
if(code == 32) {
track_url()
 
}
}

function track_url_onpaste(msg) {
status_text = trim(document.getElementById('status_message_id').value);
if(status_text == msg) {
document.getElementById('status_message_id').value = '';
}
window.setTimeout(track_url,1000);
}
var takenurl = new Array();
function track_url(){
if( document.getElementById('status_content_type')) {
 var cont_typ = document.getElementById('status_content_type').value
}
if((cont_typ == 'msg' || cont_typ == 'autolink') && takenurl.length < 3) {
var gourl = {};
var fetch_url = '';
var j = 0;
 var status_text = trim(document.getElementById('status_message_id').value);

  var newVariable = status_text.split(" ");
  for(var i= 0; i< newVariable.length; i++) {
//alert('ppp')
    if(check_it(newVariable[i])) {
     
   //  takenurl[] = newVariable[i]
      if(!searchString(takenurl,newVariable[i])) {
        if(fetch_url == '') {
          fetch_url = newVariable[i];
        }// alert('llp');
        gourl['url_'+j] = newVariable[i];
        //takenurl.unshift(newVariable[i])
        takenurl.push(newVariable[i])
        j++
      }
    
   //  alert('kk'+i+'='+ gourl[i])
    } else {
    }
  }
if(j) {
try {
//alert (gourl)
 gourl['total_urls'] = j;
 gourl['fetch_url'] = fetch_url;
 gourl['total_takenurl'] = takenurl.length;
// gourl['takenurl'] = new Array();
 for(var k = 0; k < takenurl.length; k++) {
  if(takenurl[k]) {
    gourl['takenurl_'+k] = takenurl[k]; 
  }
 }
document.getElementById('status_inner_content').style.display = 'block';
$('#status_inner_content').html('<div class="status_lnk_content" ><div class="lnk_content"><dfn style="text-align:center;"><img src="'+skin_url+'/images/loadingAnimation.gif" alt = "loading.." /></dfn></div></div>');
 $.post(
     base_url + "/ajax/fetch_content_from_site.php",
     gourl
    /*{
     'data': toJSON(gourl)
    }*/,
     function(htmlData) {//alert(htmlData);
       // $('#status_inner_content').html(htmlData);

var content_arr = eval('('+htmlData+')'); 
var con_htm = content_arr['html'];
var pic_data = content_arr['pic_data'];
$('#status_inner_content').html(con_htm);
var picdatas = pic_data[fetch_url]['pics'];
faku(picdatas);

        var act_class = '';
        var htmlTabData = '';
        for(var k = 0; k < takenurl.length; k++) {
            if(fetch_url == takenurl[k]) {
              act_class = 'activetab';
            } else {
              act_class = '';
            }
           htmlTabData += '<li><a  title = "'+takenurl[k]+'" href="javascript:void(0);" class="'+act_class+'" onclick = "change_url_container('+k+')" >'+takenurl[k].substr(0,17)+'..</a></li>';
        }
        $('#url_tabs').html(htmlTabData);
        document.getElementById('status_content_type').value = 'autolink';
     }
   );
} catch(e) {
//alert(e.message)
}
}
}
}

function check_it(url) {
     var theurl= url
     var tomatch= /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/
     if (tomatch.test(theurl))
     {
         //window.alert("URL OK.");
         return true;
     }
     else
     {
        // window.alert("URL invalid. Try again.");
         return false; 
     }
}
  function find_key(e) {     
// var rightclick;
// 	if (!e) var e = window.event;
// 	if (e.which) rightclick = (e.which == 3);
// 	else if (e.button) rightclick = (e.button == 2);
// 	alert('Rightclick: ' + rightclick); // true or false
   
      var code;
      if (!e) var e = window.event;
      if (e.keyCode) code = e.keyCode;
      else if (e.which) code = e.which;
      return code;
//       var character = String.fromCharCode(code);
//       alert('Character was ' + character);
  }

function change_status_content(typ) {//alert(typ)
//alert(takenurl)

var htmlData = ''
var htmMsg = '';
  switch (typ) {
    case 'pics':
       htmMsg = '<p>Upload photos to wall</p>';
       htmlData = '<input type="file" name="SourceFile_0" id="SourceFile_0"/>';
      document.getElementById('status_content_type').value = 'pics';
      break;
    case 'video':
       htmMsg = '<p>Upload video to wall</p>';
       htmlData = '<input type="text" name="video_url" />';
       document.getElementById('status_content_type').value = 'video';
      break;
    case 'link':
       htmMsg = '<p>Share a link with your friends</p>';
       htmlData = '<input type="text" name="mylink" id="attach_url"/><input type="button" value="Post Link" onclick = "fetch_url()"/>';
      document.getElementById('status_content_type').value = 'link';
      break;
    case 'msg':
       htmlData = '';
      document.getElementById('status_content_type').value = 'msg';
      break;
  }
  var mainHtm = '';
  if(htmlData) {
    var htmlCloseBut = '<div class="status_lnk_tabs">'+htmMsg+'<em><img onclick="close_status_content(\''+typ+'\');" src="'+skin_url+'/images_landing/close_icon.gif" /></em></div>';
    var htmlContOpen = ' <div class="status_lnk_content" >'+htmlCloseBut+'<div class="lnk_content"><dfn>';
    var htmlContClose = ' </dfn></div></div>';
    mainHtm = htmlContOpen+htmlData+htmlContClose;
  } else {
    mainHtm = '';
  }
  $('#status_inner_content').html(mainHtm);
}
var pixceldata = '';
function fetch_url() {
try {
var url = document.getElementById('attach_url').value
var gourl = {};
 if(check_it(url)) {
 gourl['fetch_url'] = url
 gourl['total_urls'] = 1;
//document.getElementById('share_main_div').style.display = 'block';
$('#status_inner_content').html('<div class="status_lnk_content" ><div class="lnk_content"><dfn style="text-align:center;"><img src="'+skin_url+'/images/loadingAnimation.gif" alt = "loading.." /></dfn></div></div>');
 $.post(
     base_url + "/ajax/fetch_content_from_site.php",
     gourl
    /*{
     'data': toJSON(gourl)
    }*/,
     function(htmlData) {//alert(htmlData);
var content_arr = eval('('+htmlData+')'); 
var con_htm = content_arr['html'];
var pic_data = content_arr['pic_data'];
$('#status_inner_content').html(con_htm);
var picdatas = pic_data[url]['pics'];
pixceldata = pic_data[url]['pics'];

faku(picdatas);

//generate_img_content(pic_data[url]['pics'])
//setTimeout("generate_img_content()", 4000);

//alert('hi2');
//alert(content_arr['html']);
//  for(var k = 0; k < takenurl.length; k++) {
//   if(takenurl[k]) {
//     gourl['takenurl_'+k] = takenurl[k]; 
//   }
//  }

     }
   );
 }
} catch(e) {alert(e.message)
}
}

var allowedpic = new Array();
function faku(picdata) {
mflag = 0;
for (var i = 0; i < picdata.length; i++) {//alert(picdata[i])
     //showImage(picdata[i])
ckimg(picdata[i])
}
// alert('pp')
// document.getElementById('link_all_img').value = mflag
//   if(mflag >1) {alert('pp')
// var htmFootr = '';
//       htmFootr = '<p><a href="javascript:void(0);" class="inactivearrow"><img src="'+skin_url+'/images_landing/left_arrow_status_Inactive.gif" /></a></p> <p><a href="javascript:void(0)" onclick = "change_link_img(\'next\')" ><img src="'+skin_url+'/images_landing/right_arrow_status.gif" /></a></p><dd id = "img_cnt_status">1 of '+mflag+' pics (Choose a Thumbnail)</dd>';
//     $('#link_img_footer').html(htmFootr);
// }
//generate_img_content();
}
//function change_link_img(containers_flag,linkimg,total_link_pics,typ){
function change_link_img(typ){
//var total_link_pics =  $('#link_all_img').value;
var total_link_pics =  document.getElementById('link_all_img').value
var upper_boundary = total_link_pics - 1;
//var linkimg =  $('#curr_img_id').value; 
var linkimg =  document.getElementById('curr_img_id').value
if(typ == 'next') {
var otherimg = 1 + parseInt(linkimg)
} else {
 var otherimg = linkimg - 1;
}
document.getElementById('curr_img_id').value = otherimg;
//$('#curr_img_id').value = otherimg;

var htmFootr = '';
if(otherimg == upper_boundary) {
htmFootr = '<p><a href="javascript:void(0);" class="inactivearrow" onclick = "change_link_img(\'prev\')"><img src="'+skin_url+'/images_landing/left_arrow_status.gif" /></a></p> <p><a href="javascript:void(0)" ><img src="'+skin_url+'/images_landing/right_arrow_status_Inactive.gif" /></a></p>';
} else if (otherimg == 0){
htmFootr = '<p><a href="javascript:void(0);" class="inactivearrow"><img src="'+skin_url+'/images_landing/left_arrow_status_Inactive.gif" /></a></p> <p><a href="javascript:void(0)" onclick = "change_link_img(\'next\')" ><img src="'+skin_url+'/images_landing/right_arrow_status.gif" /></a></p>';
} else {
htmFootr = '<p><a href="javascript:void(0);" class="inactivearrow" onclick = "change_link_img(\'prev\')"><img src="'+skin_url+'/images_landing/left_arrow_status.gif" /></a></p> <p><a href="javascript:void(0)" onclick = "change_link_img(\'next\')" ><img src="'+skin_url+'/images_landing/right_arrow_status.gif" /></a></p>';
}
var currimg = 1 + parseInt(otherimg) 
htmFootr += '<dd id = "img_cnt_status">'+currimg+' of '+total_link_pics+' pics (Choose a Thumbnail)</dd>';
$('#link_img_footer').html(htmFootr); 

for (var i=0; i < total_link_pics; i++){
  if(i == otherimg) {
    document.getElementById('actual_img_'+i).style.display = 'block';
    document.getElementById('post_link_img').value =  document.getElementById('actual_img_'+i).src 
  } else {
   document.getElementById('actual_img_'+i).style.display  = 'none';
  }
}

// if(typ == 'next') {
// var otherimg = 1 + parseInt(linkimg)
// } else {
//  var otherimg = linkimg - 1;
// }
// for (var i=0; i < total_link_pics; i++){
//   if(i == otherimg) {
//     document.getElementById('post_link_img').value =  document.getElementById('actual_img_'+containers_flag+'_'+i).src 
//     document.getElementById('link_img_'+containers_flag+'_'+i).style.display = 'block';
//   } else {
//     document.getElementById('link_img_'+containers_flag+'_'+i).style.display = 'none';
//   }
// }
}

function close_status_content(typ) {
//alert(takenurl)
 var htmlData = '';
 $('#status_inner_content').html(htmlData);
 document.getElementById('status_content_type').value = 'msg';
}

function searchString (arrayToSearch, stringToSearch) {
  arrayToSearch.sort();
  for (var i = 0; i < arrayToSearch.length; i++) {
    if (arrayToSearch[i] == stringToSearch) {
        return true;
    }
  }
  return false;
}

function change_url_container(flag) {//alert('hi');alert(flag)
 var gourl = {};
var fetch_url = takenurl[flag];
 if(check_it(fetch_url)) {
 gourl['fetch_url'] = fetch_url
 gourl['total_urls'] = 1;
//document.getElementById('share_main_div').style.display = 'block';
$('#status_inner_content').html('<div class="status_lnk_content" ><div class="lnk_content"><dfn style="text-align:center;"><img src="'+skin_url+'/images/loadingAnimation.gif" alt = "loading.." /></dfn></div></div>');
 $.post(
     base_url + "/ajax/fetch_content_from_site.php",
     gourl
    /*{
     'data': toJSON(gourl)
    }*/,
     function(htmlData) {//alert(htmlData);
      //  $('#status_inner_content').html(htmlData);
var content_arr = eval('('+htmlData+')'); 
var con_htm = content_arr['html'];
var pic_data = content_arr['pic_data'];
$('#status_inner_content').html(con_htm);
var picdatas = pic_data[fetch_url]['pics'];
faku(picdatas);
        var act_class = '';
        var htmlTabData = '';
        for(var k = 0; k < takenurl.length; k++) {
            if(fetch_url == takenurl[k]) {
              act_class = 'activetab';
            } else {
              act_class = '';
            }
           htmlTabData += '<li><a  title = "'+takenurl[k]+'" href="javascript:void(0);" class="'+act_class+'" onclick = "change_url_container('+k+')" >'+takenurl[k].substr(0,17)+'..</a></li>';
        }
        $('#url_tabs').html(htmlTabData);
     }
   );
 }
}
function CheckImgSize(imgSrc) {//alert(imgSrc)
  var newImg = new Image();
  newImg.src = imgSrc;
  var height = newImg.height;
  var width = newImg.width;
// alert(height)
// alert(width)
  if( width >30 && height >20 ) {//alert('cc')
    return true;
  } else {//alert('ff')
    return false;
  }
}



function generate_img_content() {//alert('hi');
var picdata = pixceldata
//var picdata = pixceldata

try {
var htmImgData = '';
var htmImgCntStatus = '';
//var fakerData = '';
var flag = 0;
  for (var i = 0; i < picdata.length; i++) {alert(allowedpic[picdata[i]]);//alert(picdata[i])
if ( typeof(allowedpic[picdata[i]]) != 'undefined' ) {//alert(allowedpic[picdata[i]])
   // fakerData += '<img src = "'+picdata[i]+'" />';

  //  if (showImage(picdata[i])) {//alert(htmImgData)

//alert(allowedpic[picdata[i]])

//showImage(picdata[i])

//while((allowedpic[picdata[i]] !=1) && (allowedpic[picdata[i]] != 2)) {
// showImage(picdata[i]);

// while(1) {
// showImage(picdata[i]);
// if(allowedpic[picdata[i]] ==1) {
//   break;
// }
// if(allowedpic[picdata[i]] == 2) {
//   break;
// }
// }

if (allowedpic[picdata[i]] == 1) {

       if(flag == 0) {
         htmImgData += '<img id = "actual_img_'+flag+'" src="'+picdata[i]+'"  width = "100" height = "100" style="display:block;"/>'
          //$('#curr_img_id').value = flag;
document.getElementById('curr_img_id').value = flag
       } else {
         htmImgData += '<img id = "actual_img_'+flag+'" src="'+picdata[i]+'"  width = "100" height = "100" style="display:none;"/>'
       }
      flag++;
      $('#link_content_images').html(htmImgData);
      htmImgCntStatus = '1 of '+flag+' pics (Choose a Thumbnail)';
      $('#img_cnt_status').html(htmImgCntStatus);  
    }
}
  }
  //$('#link_all_img').value = flag;
document.getElementById('link_all_img').value = flag
  if(flag >1) {
    var htmFootr = '';
      htmFootr = '<p><a href="javascript:void(0);" class="inactivearrow"><img src="'+skin_url+'/images_landing/left_arrow_status_Inactive.gif" /></a></p> <p><a href="javascript:void(0)" onclick = "change_link_img(\'next\')" ><img src="'+skin_url+'/images_landing/right_arrow_status.gif" /></a></p><dd id = "img_cnt_status">1 of '+flag+' pics (Choose a Thumbnail)</dd>';
    $('#link_img_footer').html(htmFootr);
  }

} catch(e) {//alert(e.message);
}
}

 var imgHeight = 0;
 var imgWidth = 0;
var mflag = 0;
function findHHandWW() {
//alert(this.width)
//imgHeight = this.height;imgWidth = this.width;
//alert('cc='+this.width)
var htmImgData = document.getElementById('link_content_images').innerHTML;
 var htmImgCntStatus  = '';
  if( this.width >30 && this.height >20 ) {//alert('cc')
//       htmImgData = '<img  src="'+this.src+'"  width = "100" height = "100" stsyle="display:none;"/>'
//       $('#link_content_images').html(htmImgData);
//       htmImgCntStatus = '1 of ';//+flag+' pics (Choose a Thumbnail)';
//       $('#img_cnt_status').html(htmImgCntStatus);

       if(mflag == 0) {
         htmImgData += '<img id = "actual_img_'+mflag+'" src="'+this.src+'"  width = "100" height = "100" style="display:block;"/>'
          //$('#curr_img_id').value = flag;
document.getElementById('curr_img_id').value = mflag
document.getElementById('post_link_img').value = this.src;
       } else {
         htmImgData += '<img id = "actual_img_'+mflag+'" src="'+this.src+'"  width = "100" height = "100" style="display:none;"/>'
         if(mflag == 1) {
          htmFootr = '<p><a href="javascript:void(0);" class="inactivearrow"><img src="'+skin_url+'/images_landing/left_arrow_status_Inactive.gif" /></a></p> <p><a href="javascript:void(0)" onclick = "change_link_img(\'next\')" ><img src="'+skin_url+'/images_landing/right_arrow_status.gif" /></a></p><dd id = "img_cnt_status">1 of '+mflag+' pics (Choose a Thumbnail)</dd>';
          $('#link_img_footer').html(htmFootr);
         }

       }
      mflag++;
      $('#link_content_images').html(htmImgData);
      htmImgCntStatus = '1 of '+mflag+' pics (Choose a Thumbnail)';
      $('#img_cnt_status').html(htmImgCntStatus);  
document.getElementById('link_all_img').value = mflag
    //return true;
  } else {//alert('ff')
   // allowedpic[this.src] = 2
    //return false;
  }

}

function showImage(imgPath) {
var myImage = new Image();
var randomNumber = Math.floor(Math.random()*1001);
myImage.name = imgPath;
myImage.onload = findHHandWW;
//myImage.src = imgPath;
myImage.src = imgPath + '?random=' + randomNumber;
}


function CreateDelegate(contextObject, delegateMethod)
{
    return function()
    {
        return delegateMethod.apply(contextObject, arguments);
    }
}

function imgTesting_onload()
{
//alert(this.width)
//imgHeight = this.height;imgWidth = this.width;
//alert('cc='+this.width)
var htmImgData = document.getElementById('link_content_images').innerHTML;
 var htmImgCntStatus  = '';
  if( this.width >30 && this.height >20 ) {//alert('cc')
//       htmImgData = '<img  src="'+this.src+'"  width = "100" height = "100" stsyle="display:none;"/>'
//       $('#link_content_images').html(htmImgData);
//       htmImgCntStatus = '1 of ';//+flag+' pics (Choose a Thumbnail)';
//       $('#img_cnt_status').html(htmImgCntStatus);

       if(mflag == 0) {
         htmImgData += '<img id = "actual_img_'+mflag+'" src="'+this.src+'"  width = "100" height = "100" style="display:block;"/>'
          //$('#curr_img_id').value = flag;
document.getElementById('curr_img_id').value = mflag
document.getElementById('post_link_img').value = this.src;
       } else {
         htmImgData += '<img id = "actual_img_'+mflag+'" src="'+this.src+'"  width = "100" height = "100" style="display:none;"/>'
         if(mflag == 1) {
          htmFootr = '<p><a href="javascript:void(0);" class="inactivearrow"><img src="'+skin_url+'/images_landing/left_arrow_status_Inactive.gif" /></a></p> <p><a href="javascript:void(0)" onclick = "change_link_img(\'next\')" ><img src="'+skin_url+'/images_landing/right_arrow_status.gif" /></a></p><dd id = "img_cnt_status">1 of '+mflag+' pics (Choose a Thumbnail)</dd>';
          $('#link_img_footer').html(htmFootr);
         }

       }
      mflag++;
      $('#link_content_images').html(htmImgData);
      htmImgCntStatus = '1 of '+mflag+' pics (Choose a Thumbnail)';
      $('#img_cnt_status').html(htmImgCntStatus);  
document.getElementById('link_all_img').value = mflag
    //return true;
  } else {//alert('ff')
   // allowedpic[this.src] = 2
    //return false;
  }

}

function ckimg(im) {
var imgTesting = new Image();
imgTesting.onload = CreateDelegate(imgTesting, imgTesting_onload);
imgTesting.src = im;
}

function no_thumb_chk(obj) {
  if(obj.checked == true) {
    $('#link_img_footer').css('display', 'none');
    var currimg = document.getElementById('curr_img_id').value
    $('#actual_img_'+currimg).css('display', 'none');
  } else {
    $('#link_img_footer').css('display', 'block');
    var currimg = document.getElementById('curr_img_id').value
    $('#actual_img_'+currimg).css('display', 'block');
  }
}